MCPcopy Create free account
hub / github.com/MaxBelkov/visualsyslog / Open

Method Open

sourcecommon/udp.cpp:62–175  ·  view source on GitHub ↗

---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

60}
61//---------------------------------------------------------------------------
62bool TUDP::Open(char * local, WORD lport, char * dest, WORD dport)
63{
64 Error = 0;
65 WSAError = 0;
66
67 if( handle || !local || !dest )
68 {
69 WSAError = MYERROR_UNKNOWNPARAMS;
70 Error = 1;
71 if( Exceptions ) throw 0;
72 return !Error;
73 }
74
75 in_addr l;
76 l.S_un.S_addr = inet_addr(local);
77 if( l.S_un.S_addr==4294967295 ) // host name OR error in IP address
78 {
79 // try to resolve host name and copy to l
80 HOSTENT * hostent = gethostbyname(local);
81 if( hostent )
82 {
83 // hostent->h_name ---> Full local name
84 l.S_un = ((in_addr *)hostent->h_addr_list[0])->S_un;
85 }
86 else
87 {
88 //l.S_un.S_addr = INADDR_ANY; // ��������� ����� ����� ���� �������
89 WSAError = WSAGetLastError();
90 Error = 2;
91 if( Exceptions ) throw 0;
92 return !Error;
93 }
94 }
95
96 in_addr d;
97 d.S_un.S_addr = inet_addr(dest);
98 if( d.S_un.S_addr==4294967295 ) // host name OR error in IP address
99 {
100 // try to resolve host name and copy to d
101 HOSTENT * hostent = gethostbyname(dest);
102 if( hostent )
103 {
104 // hostent->h_name ---> Full dest name
105 d.S_un = ((in_addr *)hostent->h_addr_list[0])->S_un;
106 }
107 else
108 {
109 //d.S_un.S_addr = INADDR_ANY; // ��������� ����� ����� ���� �������
110 WSAError = WSAGetLastError();
111 Error = 3;
112 if( Exceptions ) throw 0;
113 return !Error;
114 }
115 }
116
117 SOCKET h;
118
119 // open a TCP socket

Callers 5

SaveMethod · 0.45
UdpServerStartFunction · 0.45
TcpServerStartFunction · 0.45
SetFileMethod · 0.45
WriteToLogRawMessageFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected