| 145 | } |
| 146 | |
| 147 | static 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 | |
| 172 | static void GetAddrInfo(const std::string& name) |
| 173 | { |
no test coverage detected
searching dependent graphs…