free(self);
}
+#ifdef WIN32
+static inet_pton_func inet_pton_ptr = NULL;
+static HMODULE ws2_hnd = NULL;
+#else
+static inet_pton_func inet_pton_ptr = inet_pton;
+#endif /* WIN32 */
+
#if defined(_MSC_VER) && (_MSC_VER < 1300)
static freeaddrinfo_func freeaddrinfo_ptr = NULL;
static getaddrinfo_func getaddrinfo_ptr = NULL;
static getnameinfo_func getnameinfo_ptr = NULL;
-static HMODULE ws2_hnd = NULL;
#else
static freeaddrinfo_func freeaddrinfo_ptr = freeaddrinfo;
static getaddrinfo_func getaddrinfo_ptr = getaddrinfo;
static int
is_numeric_address(const char *hostname)
{
- char unused[16];
- return (inet_pton(AF_INET, hostname, &unused) ||
- inet_pton(AF_INET6, hostname, &unused));
+ if (inet_pton_ptr != NULL)
+ {
+ char unused[16];
+ return (inet_pton_ptr(AF_INET, hostname, &unused) ||
+ inet_pton_ptr(AF_INET6, hostname, &unused));
+ }
+ return (inet_addr(hostname) != INADDR_NONE);
}
char
return 0;
}
-#if defined(_MSC_VER) && (_MSC_VER < 1300)
+#ifdef WIN32
if (ws2_hnd == NULL)
+ {
ws2_hnd = GetModuleHandle("ws2_32.dll");
+ if (inet_pton_ptr == NULL)
+ inet_pton_ptr = (inet_pton_func)GetProcAddress(ws2_hnd, "inet_pton");
+ }
+#endif /* WIN32 */
+#if defined(_MSC_VER) && (_MSC_VER < 1300)
if (freeaddrinfo_ptr == NULL)
freeaddrinfo_ptr = (freeaddrinfo_func)GetProcAddress(ws2_hnd, "freeaddrinfo");
if (getaddrinfo_ptr == NULL)
const struct addrinfo *, struct addrinfo **);
typedef int (WSAAPI *getnameinfo_func) (const struct sockaddr *,
socklen_t, char *, size_t, char *, size_t, int);
+typedef int (WSAAPI *inet_pton_func) (int, const char *, void *);
#ifdef MSG_NOSIGNAL
#define SEND_FLAG MSG_NOSIGNAL