Index: win32/win32.c =================================================================== --- win32/win32.c (révision 13588) +++ win32/win32.c (copie de travail) @@ -2244,7 +2244,7 @@ // initalize the winsock interface and insure that it's // cleaned up at exit. // - version = MAKEWORD(2, 0); + version = MAKEWORD(2, 2); if (WSAStartup(version, &retdata)) rb_fatal ("Unable to locate winsock library!\n"); if (LOBYTE(retdata.wVersion) != 2) Index: ext/socket/extconf.rb =================================================================== --- ext/socket/extconf.rb (révision 13588) +++ ext/socket/extconf.rb (copie de travail) @@ -33,8 +33,15 @@ default_ipv6 = /cygwin/ !~ RUBY_PLATFORM if enable_config("ipv6", default_ipv6) if checking_for("ipv6") {try_link(< +#include +#include +#else #include #include +#endif main() { socket(AF_INET6, SOCK_STREAM, 0); @@ -107,6 +114,12 @@ getaddr_info_ok = enable_config("wide-getaddrinfo") do checking_for("wide getaddrinfo") {try_run(< +#include +#include +#endif #include #ifndef EXIT_SUCCESS @@ -126,6 +139,18 @@ struct addrinfo hints, *ai, *aitop; char straddr[INET6_ADDRSTRLEN], strport[16]; +#ifdef _WIN32 + WORD version; + WSADATA retdata; + + version = MAKEWORD(2, 2); + if (WSAStartup(version, &retdata) || (LOBYTE(retdata.wVersion) != 2)) + { + printf("Unable to locate winsock library!"); + goto bad; + } +#endif + for (passive = 0; passive <= 1; passive++) { memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; @@ -199,11 +224,17 @@ if (aitop) freeaddrinfo(aitop); +#ifdef _WIN32 + WSACleanup(); +#endif exit(EXIT_SUCCESS); bad: if (aitop) freeaddrinfo(aitop); +#ifdef _WIN32 + WSACleanup(); +#endif exit(EXIT_FAILURE); } EOF @@ -216,6 +247,8 @@ you cannot compile IPv6 socket classes with broken these functions. You can try --enable-wide-getaddrinfo. EOS +else + $defs << "-DHAVE_GETADDRINFO" end case with_config("lookup-order-hack", "UNSPEC") @@ -234,7 +267,12 @@ $objs = ["socket.#{$OBJEXT}"] -unless getaddr_info_ok and have_func("getnameinfo", "netdb.h") and have_func("getaddrinfo", "netdb. h") +unless getaddr_info_ok + unless $mswin or $bccwin or $mingw + have_func("getnameinfo", "netdb.h") and have_func("getaddrinfo", "netdb.h") + else + have_func("getnameinfo", "WS2tcpip.h") and have_func("getaddrinfo", "WS2tcpip.h") + end if have_struct_member("struct in6_addr", "s6_addr8", headers) $defs[-1] = "-DHAVE_ADDR8" end @@ -248,9 +286,11 @@ have_header("resolv.h") end +unless $mswin or $bccwin or $mingw unless have_type("socklen_t", headers) $defs << "-Dsocklen_t=int" end +end have_header("sys/un.h") have_header("sys/uio.h") Index: ext/socket/socket.c =================================================================== --- ext/socket/socket.c (révision 13588) +++ ext/socket/socket.c (copie de travail) @@ -25,6 +25,10 @@ #include #endif +#ifdef _WIN32 +#include +#endif + #ifndef _WIN32 #if defined(__BEOS__) # include @@ -2185,6 +2189,10 @@ ptr = RSTRING_PTR(domain); if (strcmp(ptr, "AF_INET") == 0) *dv = AF_INET; +#ifdef AF_INET6 + else if (strcmp(ptr, "AF_INET6") == 0) + *dv = AF_INET6; +#endif #ifdef AF_UNIX else if (strcmp(ptr, "AF_UNIX") == 0) *dv = AF_UNIX; @@ -2205,6 +2213,10 @@ else if (strcmp(ptr, "PF_INET") == 0) *dv = PF_INET; #endif +#ifdef PF_INET6 + else if (strcmp(ptr, "PF_INET6") == 0) + *dv = PF_INET6; +#endif #ifdef PF_UNIX else if (strcmp(ptr, "PF_UNIX") == 0) *dv = PF_UNIX;