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

Function SetAddr

example_poll.cpp:63–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61
62
63static void SetAddr(const char *pszIP,const unsigned short shPort,struct sockaddr_in &addr)
64{
65 bzero(&addr,sizeof(addr));
66 addr.sin_family = AF_INET;
67 addr.sin_port = htons(shPort);
68 int nIP = 0;
69 if( !pszIP || '\0' == *pszIP
70 || 0 == strcmp(pszIP,"0") || 0 == strcmp(pszIP,"0.0.0.0")
71 || 0 == strcmp(pszIP,"*")
72 )
73 {
74 nIP = htonl(INADDR_ANY);
75 }
76 else
77 {
78 nIP = inet_addr(pszIP);
79 }
80 addr.sin_addr.s_addr = nIP;
81
82}
83
84static int CreateTcpSocket(const unsigned short shPort = 0 ,const char *pszIP = "*" ,bool bReuse = false )
85{

Callers 2

CreateTcpSocketFunction · 0.70
mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected