MCPcopy Create free account
hub / github.com/acl-dev/acl / GetHostByname

Function GetHostByname

lib_fiber/samples-gui/SimpleWin/SimpleWin.cpp:147–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145}
146
147static bool GetHostByname(const char* name, std::vector<std::string>* addrs)
148{
149 printf("\r\n");
150 printf(">>>call gethostbyname, name=%s, thread=%d\r\n", name, GetCurrentThreadId());
151 struct hostent* ent = gethostbyname(name);
152 if (ent == NULL) {
153 printf("gethostbyname error, name=%s, thread=%d\r\n", name, GetCurrentThreadId());
154 return false;
155 }
156
157 for (int i = 0; ent->h_addr_list[i]; i++) {
158 char* addr = ent->h_addr_list[i];
159 char ip[64];
160 const char* ptr = inet_ntop(ent->h_addrtype, addr, ip, sizeof(ip));
161 if (ptr) {
162 addrs->push_back(ptr);
163 }
164 else {
165 printf(">>>inet_ntop error\r\n");
166 }
167 }
168
169 return true;
170}
171
172static void GetAddrInfo(const std::string& name)
173{

Callers 1

WndProcFunction · 0.85

Calls 3

inet_ntopFunction · 0.85
gethostbynameFunction · 0.50
push_backMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…