X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-poll.c;h=d78698e4a585bcd4a0c3bd132d1f1043a2c5d572;hb=9cedf3e1ac7dbdddefb7e172156e9000de7d80c2;hp=5e8d70614feb4490df94a95e11d3237b14bea956;hpb=54898f0a60a82dd7e9225e97288cb85eeb77f476;p=gnulib.git diff --git a/tests/test-poll.c b/tests/test-poll.c index 5e8d70614..d78698e4a 100644 --- a/tests/test-poll.c +++ b/tests/test-poll.c @@ -1,5 +1,5 @@ /* Test of poll() function. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2009 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,8 +28,8 @@ #include #include #include +#include #include -#include "sockets.h" #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # define WIN32_NATIVE @@ -129,26 +129,22 @@ connect_to_socket (int blocking) { #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); - + if (!(oldflags & O_NONBLOCK)) fcntl (s, F_SETFL, oldflags | O_NONBLOCK); #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; } @@ -165,7 +161,7 @@ poll1 (int fd, int ev, int time) pfd.fd = fd; pfd.events = ev; pfd.revents = 0; - r = poll (&pfd, 1, time); + r = poll (&pfd, 1, time); if (r < 0) return r; @@ -363,8 +359,6 @@ main () { int result; - gl_sockets_startup (SOCKETS_2_0); - #ifdef INTERACTIVE printf ("Please press Enter\n"); test (test_tty, "TTY");