MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / _Resolve

Function _Resolve

cpp/src/platform/HttpClient.cpp:237–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237static bool _Resolve
238(
239const char *host,
240unsigned int port,
241struct 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

Callers 1

_openSocketFunction · 0.85

Calls 3

_GetErrorStrFunction · 0.85
_GetErrorFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected