diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2006-01-26 09:39:01 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2006-01-26 09:39:01 +0000 |
commit | bcd4b40e67010378892ce56f551d9e45958f07fa (patch) | |
tree | e5fe07cbe90198d788a74dc3a3189d0094e2fcdd /libsylph | |
parent | d8eebab473de16ec293a53a3bab46f4fce787dc2 (diff) |
supported IPv6 on Win32.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@932 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r-- | libsylph/socket.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/libsylph/socket.c b/libsylph/socket.c index e0ca1fa5..834f760b 100644 --- a/libsylph/socket.c +++ b/libsylph/socket.c @@ -26,6 +26,7 @@ #include <sys/types.h> #ifdef G_OS_WIN32 # include <winsock2.h> +# include <ws2tcpip.h> #else # if HAVE_SYS_WAIT_H # include <sys/wait.h> @@ -635,9 +636,27 @@ static gint sock_connect_by_hostname(gint sock, const gchar *hostname, } #else /* INET6 */ + +#ifdef G_OS_WIN32 +/* MinGW defines gai_strerror() in ws2tcpip.h, but it is not implemented. */ +#undef gai_strerror +const gchar *gai_strerror(gint errcode) +{ + static gchar str[32]; + + g_snprintf(str, sizeof(str), "gai errcode: (%d)", errcode); + return str; +} +#endif + static gint sock_connect_by_getaddrinfo(const gchar *hostname, gushort port) { - gint sock = -1, gai_error; +#ifdef G_OS_WIN32 + SOCKET sock = INVALID_SOCKET; +#else + gint sock = -1; +#endif + gint gai_error; struct addrinfo hints, *res, *ai; gchar port_str[6]; @@ -658,7 +677,11 @@ static gint sock_connect_by_getaddrinfo(const gchar *hostname, gushort port) for (ai = res; ai != NULL; ai = ai->ai_next) { sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); +#ifdef G_OS_WIN32 + if (sock == INVALID_SOCKET) +#else if (sock < 0) +#endif continue; if (sock_connect_with_timeout @@ -688,7 +711,12 @@ SockInfo *sock_connect(const gchar *hostname, gushort port) SockInfo *sockinfo; #ifdef INET6 +#ifdef G_OS_WIN32 + if ((sock = sock_connect_by_getaddrinfo(hostname, port)) + == INVALID_SOCKET) +#else if ((sock = sock_connect_by_getaddrinfo(hostname, port)) < 0) +#endif /* G_OS_WIN32 */ return NULL; #else #ifdef G_OS_WIN32 |