85a2ebc1c4
Issue #1082
38 lines
944 B
Diff
38 lines
944 B
Diff
+++ src/lib/sdl_net/SDLnet.c
|
|
@@ -122,11 +122,11 @@
|
|
} else {
|
|
address->host = inet_addr(host);
|
|
if ( address->host == INADDR_NONE ) {
|
|
- struct hostent *hp;
|
|
+ struct addrinfo *ai;
|
|
|
|
- hp = gethostbyname(host);
|
|
- if ( hp ) {
|
|
- memcpy(&address->host,hp->h_addr,hp->h_length);
|
|
+ retval = getaddrinfo(host, NULL, NULL, &ai);
|
|
+ if ( retval == 0 ) {
|
|
+ memcpy(&address->host,ai->ai_addr,ai->ai_addrlen);
|
|
} else {
|
|
retval = -1;
|
|
}
|
|
@@ -149,12 +149,15 @@
|
|
*/
|
|
const char *SDLNet_ResolveIP(const IPaddress *ip)
|
|
{
|
|
- struct hostent *hp;
|
|
+ static char host[256];
|
|
struct in_addr in;
|
|
+ int err;
|
|
|
|
- hp = gethostbyaddr((const char *)&ip->host, sizeof(ip->host), AF_INET);
|
|
- if ( hp != NULL ) {
|
|
- return hp->h_name;
|
|
+ err = getnameinfo((const struct sockaddr*) &ip->host,
|
|
+ sizeof (struct sockaddr), host, sizeof (host),
|
|
+ NULL, 0, 0);
|
|
+ if ( err == 0 ) {
|
|
+ return host;
|
|
}
|
|
|
|
in.s_addr = ip->host;
|