| 235 | } |
| 236 | |
| 237 | static bool _Resolve |
| 238 | ( |
| 239 | const char *host, |
| 240 | unsigned int port, |
| 241 | struct sockaddr_in *addr |
| 242 | ) |
| 243 | { |
| 244 | char port_str[16]; |
| 245 | sprintf(port_str, "%u", port); |
| 246 | |
| 247 | struct addrinfo hnt, *res = 0; |
| 248 | memset(&hnt, 0, sizeof(hnt)); |
| 249 | hnt.ai_family = AF_INET; |
| 250 | hnt.ai_socktype = SOCK_STREAM; |
| 251 | if (getaddrinfo(host, port_str, &hnt, &res)) |
| 252 | { |
| 253 | traceprint("RESOLVE ERROR: %s", _GetErrorStr(_GetError()).c_str()); |
| 254 | return false; |
| 255 | } |
| 256 | if (res) |
| 257 | { |
| 258 | if (res->ai_family != AF_INET) |
| 259 | { |
| 260 | traceprint("RESOLVE WTF: %s", _GetErrorStr(_GetError()).c_str()); |
| 261 | freeaddrinfo(res); |
| 262 | return false; |
| 263 | } |
| 264 | memcpy(addr, res->ai_addr, res->ai_addrlen); |
| 265 | freeaddrinfo(res); |
| 266 | return true; |
| 267 | } |
| 268 | return false; |
| 269 | } |
| 270 | |
| 271 | // FIXME: this does currently not handle links like: |
| 272 | // http://example.com/index.html#pos |
no test coverage detected