#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#ifdef HAVE_GETOPT_H
# include <getopt.h>
#endif
-#ifdef SOCKET_AVAIL
-#include <sys/socket.h>
+#ifdef _WIN32
+# include <winsock2.h>
+# define SOCKET_AVAIL
+#elif defined HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
#endif
#include <ctype.h>
#include <errno.h>