MCPcopy Create free account
hub / github.com/Tencent/libco / SetAddr

Function SetAddr

example_echosvr.cpp:154–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154static void SetAddr(const char *pszIP,const unsigned short shPort,struct sockaddr_in &addr)
155{
156 bzero(&addr,sizeof(addr));
157 addr.sin_family = AF_INET;
158 addr.sin_port = htons(shPort);
159 int nIP = 0;
160 if( !pszIP || '\0' == *pszIP
161 || 0 == strcmp(pszIP,"0") || 0 == strcmp(pszIP,"0.0.0.0")
162 || 0 == strcmp(pszIP,"*")
163 )
164 {
165 nIP = htonl(INADDR_ANY);
166 }
167 else
168 {
169 nIP = inet_addr(pszIP);
170 }
171 addr.sin_addr.s_addr = nIP;
172
173}
174
175static int CreateTcpSocket(const unsigned short shPort /* = 0 */,const char *pszIP /* = "*" */,bool bReuse /* = false */)
176{

Callers 1

CreateTcpSocketFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected