--- deliantra/server/socket/init.C 2006/09/20 21:53:50 1.9 +++ deliantra/server/socket/init.C 2006/12/11 19:46:47 1.10 @@ -37,13 +37,11 @@ #ifndef __CEXTRACT__ # include #endif -#ifndef WIN32 /* ---win32 exclude include files */ -# include -# include -# include -# include -# include -#endif /* win32 */ +#include +#include +#include +#include +#include #ifdef HAVE_UNISTD_H # include @@ -71,17 +69,10 @@ int oldbufsize; int buflen = sizeof (int); -#ifdef WIN32 /* ***WIN32 SOCKET: init win32 non blocking socket */ - int temp = 1; - - if (ioctlsocket (ns->fd, FIONBIO, &temp) == -1) - LOG (llevError, "InitConnection: Error on ioctlsocket.\n"); -#else if (fcntl (ns->fd, F_SETFL, O_NONBLOCK) == -1) { LOG (llevError, "InitConnection: Error on fcntl.\n"); } -#endif /* end win32 */ if (getsockopt (ns->fd, SOL_SOCKET, SO_SNDBUF, (char *) &oldbufsize, (socklen_t *) & buflen) == -1) oldbufsize = 0; @@ -181,25 +172,15 @@ struct protoent *protox; struct linger linger_opt; -#ifdef WIN32 /* ***win32 - we init a windows socket */ - WSADATA w; - - socket_info.max_filedescriptor = 1; /* used in select, ignored in winsockets */ - WSAStartup (0x0101, &w); /* this setup all socket stuff */ - /* ill include no error tests here, winsocket 1.1 should always work */ - /* except some old win95 versions without tcp/ip stack */ -#else /* non windows */ - -# ifdef HAVE_SYSCONF +#ifdef HAVE_SYSCONF socket_info.max_filedescriptor = sysconf (_SC_OPEN_MAX); -# else -# ifdef HAVE_GETDTABLESIZE +#else +# ifdef HAVE_GETDTABLESIZE socket_info.max_filedescriptor = getdtablesize (); -# else +# else "Unable to find usable function to get max filedescriptors"; -# endif # endif -#endif /* win32 */ +#endif socket_info.timeout.tv_sec = 0; socket_info.timeout.tv_usec = 0; @@ -251,11 +232,7 @@ defined(WIN32) /* ---win32 add this here */ || \ defined(__GNU__) /* HURD */ { -# ifdef WIN32 - char tmp = 1; -# else int tmp = 1; -# endif if (setsockopt (init_sockets[0].fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof (tmp))) { @@ -272,23 +249,13 @@ if (bind (init_sockets[0].fd, (struct sockaddr *) &insock, sizeof (insock)) == (-1)) { LOG (llevError, "Cannot bind socket to port %d: %s\n", ntohs (insock.sin_port), strerror (errno)); -#ifdef WIN32 /* ***win32: close() -> closesocket() */ - shutdown (init_sockets[0].fd, SD_BOTH); - closesocket (init_sockets[0].fd); -#else close (init_sockets[0].fd); -#endif /* win32 */ exit (-1); } if (listen (init_sockets[0].fd, 5) == (-1)) { LOG (llevError, "Cannot listen on socket: %s\n", strerror (errno)); -#ifdef WIN32 /* ***win32: close() -> closesocket() */ - shutdown (init_sockets[0].fd, SD_BOTH); - closesocket (init_sockets[0].fd); -#else close (init_sockets[0].fd); -#endif /* win32 */ exit (-1); } init_sockets[0].status = Ns_Add; @@ -321,14 +288,8 @@ void free_newsocket (NewSocket * ns) { -#ifdef WIN32 /* ***win32: closesocket in windows style */ - shutdown (ns->fd, SD_BOTH); - if (closesocket (ns->fd)) - { -#else if (close (ns->fd)) { -#endif /* win32 */ #ifdef ESRV_DEBUG LOG (llevDebug, "Error closing socket %d\n", ns->fd);