Changes for mingw32 compatibility. Gave up using GetAddrInfoW. getaddrinfo is dynamically bound, gethostbyname is used if it is not available.

VC compilation is broken.

Make sure to use the dynamic boost-thread lib with mingw, as thread specific pointers are used!
This commit is contained in:
lotodore
2007-09-01 14:04:41 +00:00
parent 26397dee94
commit 1f6a10e2d1
9 changed files with 100 additions and 99 deletions
+27 -1
View File
@@ -37,6 +37,32 @@ socket_string_to_addr(const char *str, int addrFamily, struct sockaddr * addr, i
bool
socket_resolve(const char *str, const char *port, int addrFamily, int sockType, int protocol, struct sockaddr *addr, int addrLen)
{
return internal_socket_resolve(str, port, addrFamily, sockType, protocol, addr, addrLen);
bool retVal = false;
if (str && *str != 0)
{
struct addrinfo aiHints;
struct addrinfo *aiList = NULL;
memset(&aiHints, 0, sizeof(aiHints));
aiHints.ai_family = addrFamily;
aiHints.ai_socktype = sockType;
aiHints.ai_protocol = protocol;
// Try to resolve the name.
// Will (hopefully) use UTF-8 if called on Linux.
bool success = (getaddrinfo(str, port, &aiHints, &aiList) == 0);
if (success && aiList)
{
if ((int)aiList->ai_addrlen <= addrLen)
{
memcpy(addr, aiList->ai_addr, aiList->ai_addrlen);
retVal = true;
}
freeaddrinfo(aiList);
}
}
return retVal;
}