Fixed name resolution on Windows 2000.
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
using namespace std;
|
||||
|
||||
typedef int (WSAAPI * getaddrinfo_ptr_t) (const char *, const char* , const struct addrinfo *, struct addrinfo **);
|
||||
typedef void (WSAAPI * freeaddrinfo_ptr_t) (struct addrinfo*);
|
||||
typedef void (WSAAPI * freeaddrinfo_ptr_t) (struct addrinfo*);
|
||||
|
||||
static wstring
|
||||
utf8ToWchar(const char *str)
|
||||
@@ -119,12 +119,15 @@ socket_resolve(const char *str, const char *port, int addrFamily, int sockType,
|
||||
}
|
||||
// If we cannot use getaddrinfo (OS older than XP),
|
||||
// we call the "classic" gethostbyname.
|
||||
if (!useGetaddrinfo && protocol == AF_INET)
|
||||
if (!useGetaddrinfo && addrFamily == AF_INET)
|
||||
{
|
||||
struct hostent *host = gethostbyname(str);
|
||||
if (host && host->h_addr_list)
|
||||
{
|
||||
memcpy(addr, host->h_addr_list, host->h_length);
|
||||
struct sockaddr_in *addr_in = (struct sockaddr_in *)addr;
|
||||
addr_in->sin_family = AF_INET;
|
||||
addr_in->sin_port = htons(atoi(port));
|
||||
memcpy(&addr_in->sin_addr, host->h_addr_list[0], host->h_length);
|
||||
retVal = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user