X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-poll.c;h=b0cdb6087a7ce2d19a3371428d719b04ef3a2183;hb=8df2459e40ab2ee726f4532c0699d4f7a40717d0;hp=0dbcb54fbeb7d8485719d698d0a3f116e6874875;hpb=b03b6bfb8daa20dceff4593229f0df2c68c37e6e;p=gnulib.git diff --git a/tests/test-poll.c b/tests/test-poll.c index 0dbcb54fb..b0cdb6087 100644 --- a/tests/test-poll.c +++ b/tests/test-poll.c @@ -31,7 +31,11 @@ #include #include "sockets.h" -#ifdef HAVE_IO_H +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# define WIN32_NATIVE +#endif + +#ifdef WIN32_NATIVE #include #define pipe(x) _pipe(x, 256, O_BINARY) #endif @@ -123,9 +127,9 @@ connect_to_socket (int blocking) if (!blocking) { -#ifdef __MSVCRT__ +#ifdef WIN32_NATIVE unsigned long iMode = 1; - ioctlsocket (s, FIONBIO, (void *) &iMode); + ioctl (s, FIONBIO, (char *) &iMode); #elif defined F_GETFL int oldflags = fcntl (s, F_GETFL, NULL); @@ -135,16 +139,12 @@ connect_to_socket (int blocking) #endif } - if (connect (s, (struct sockaddr *) &ia, sizeof (ia)) < 0) + if (connect (s, (struct sockaddr *) &ia, sizeof (ia)) < 0 + && (blocking || errno != EINPROGRESS)) { - if (errno != EINPROGRESS) - { - perror ("connect"); - exit (77); - } + perror ("connect"); + exit (77); } - else if (!blocking) - failed ("huh, connect succeeded?"); return s; } @@ -241,7 +241,7 @@ test_connect_first (void) static void test_accept_first (void) { -#ifndef __MSVCRT__ +#ifndef WIN32_NATIVE int s = open_server_socket (); struct sockaddr_in ia; socklen_t addrlen; @@ -359,7 +359,7 @@ main () { int result; - gl_sockets_startup (SOCKETS_2_0); + gl_sockets_startup (SOCKETS_1_1); #ifdef INTERACTIVE printf ("Please press Enter\n");