Request only IP4 addresses for the moment, further work required to deal with IP6 addresses.
This commit is contained in:
parent
09e610b900
commit
2f9ba31b0a
@ -115,12 +115,18 @@ void IPAddress::set ( const char* host, int port )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct addrinfo hints;
|
||||||
|
memset(&hints, 0, sizeof(struct addrinfo));
|
||||||
|
hints.ai_family = AF_INET;
|
||||||
|
|
||||||
struct addrinfo* result = NULL;
|
struct addrinfo* result = NULL;
|
||||||
int err = getaddrinfo(host, NULL, NULL /* no hints */, &result);
|
int err = getaddrinfo(host, NULL, NULL /* no hints */, &result);
|
||||||
if (err) {
|
if (err) {
|
||||||
SG_LOG(SG_IO, SG_WARN, "getaddrinfo failed for '" << host << "' : " << gai_strerror(err));
|
SG_LOG(SG_IO, SG_WARN, "getaddrinfo failed for '" << host << "' : " << gai_strerror(err));
|
||||||
} else if (result->ai_addrlen != getAddrLen()) {
|
} else if (result->ai_addrlen != getAddrLen()) {
|
||||||
SG_LOG(SG_IO, SG_ALERT, "mismatch in socket address sizes");
|
SG_LOG(SG_IO, SG_ALERT, "mismatch in socket address sizes: got " <<
|
||||||
|
result->ai_addrlen << ", expected " << getAddrLen());
|
||||||
|
SG_LOG(SG_IO, SG_ALERT, "family:" << result->ai_family);
|
||||||
} else {
|
} else {
|
||||||
memcpy(addr, result->ai_addr, result->ai_addrlen);
|
memcpy(addr, result->ai_addr, result->ai_addrlen);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user