#include <errno.h>
#include "sockets.h"
-#ifdef HAVE_IO_H
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# define WIN32_NATIVE
+#endif
+
+#ifdef WIN32_NATIVE
#include <io.h>
#define pipe(x) _pipe(x, 256, O_BINARY)
#endif
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);
#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;
}
static void
test_accept_first (void)
{
-#ifndef __MSVCRT__
+#ifndef WIN32_NATIVE
int s = open_server_socket ();
struct sockaddr_in ia;
socklen_t addrlen;
{
int result;
- gl_sockets_startup (SOCKETS_2_0);
+ gl_sockets_startup (SOCKETS_1_1);
#ifdef INTERACTIVE
printf ("Please press Enter\n");