engine: gethostbyname() is deprecated, remove it and always prefer getaddrinfo

This commit is contained in:
Alibek Omarov
2025-09-29 00:09:56 +05:00
parent 7c0045a3b7
commit e83ab95279
3 changed files with 0 additions and 24 deletions
-21
View File
@@ -237,7 +237,6 @@ NET_GetHostByName
*/
static qboolean NET_GetHostByName( const char *hostname, int family, struct sockaddr_storage *addr )
{
#if defined HAVE_GETADDRINFO
struct addrinfo *ai = NULL, *cur;
struct addrinfo hints;
qboolean ret = false;
@@ -267,22 +266,6 @@ static qboolean NET_GetHostByName( const char *hostname, int family, struct sock
}
return ret;
#else
struct hostent *h;
#if XASH_NO_IPV6_RESOLVE
if( family == AF_INET6 )
return false;
#endif
if(!( h = gethostbyname( hostname )))
return false;
((struct sockaddr_in *)addr)->sin_family = AF_INET;
((struct sockaddr_in *)addr)->sin_addr = *(struct in_addr *)h->h_addr_list[0];
return true;
#endif
}
#if !XASH_EMSCRIPTEN && !XASH_DOS4GW && !defined XASH_NO_ASYNC_NS_RESOLVE
@@ -380,11 +363,7 @@ static void NET_ResolveThread( void )
RESOLVE_DBG( "[resolve thread] starting resolve for " );
RESOLVE_DBG( nsthread.hostname );
#ifdef HAVE_GETADDRINFO
RESOLVE_DBG( " with getaddrinfo\n" );
#else
RESOLVE_DBG( " with gethostbyname\n" );
#endif
if(( res = NET_GetHostByName( nsthread.hostname, nsthread.family, &addr )))
RESOLVE_DBG( "[resolve thread] success\n" );
-1
View File
@@ -73,7 +73,6 @@ GNU General Public License for more details.
#ifndef XASH_DOS4GW
#define HAVE_GETADDRINFO
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
-2
View File
@@ -18,6 +18,4 @@ GNU General Public License for more details.
#include <WS2tcpip.h>
typedef int WSAsize_t;
#define HAVE_GETADDRINFO
#endif // NET_H