diff options
author | Martin Ebourne <martin@ebourne.me.uk> | 2005-12-12 20:50:00 +0000 |
---|---|---|
committer | Martin Ebourne <martin@ebourne.me.uk> | 2005-12-12 20:50:00 +0000 |
commit | 3bedf8846f4d7a5cb38276b274662d62a36dcd52 (patch) | |
tree | 9d51de8b0f3d06ba6549a5a1958e52f592343140 /lib/server/SocketListen.h | |
parent | 81d8eda2419e7a23088a98cdfc52a305c9ceac0d (diff) |
Marged chris/win32/merge/07-win32-fixes at r210 to trunk
Diffstat (limited to 'lib/server/SocketListen.h')
-rwxr-xr-x | lib/server/SocketListen.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/server/SocketListen.h b/lib/server/SocketListen.h index 7042011c..d954339a 100755 --- a/lib/server/SocketListen.h +++ b/lib/server/SocketListen.h @@ -12,15 +12,20 @@ #include <errno.h> #include <unistd.h> -#include <new> -#include <poll.h> -#include <memory> -#include <string> + #ifdef HAVE_KQUEUE #include <sys/event.h> #include <sys/time.h> #endif +#ifndef WIN32 + #include <poll.h> +#endif + +#include <new> +#include <memory> +#include <string> + #include "Socket.h" #include "ServerException.h" @@ -94,7 +99,11 @@ public: { if(mSocketHandle != -1) { +#ifdef WIN32 + if(::closesocket(mSocketHandle) == -1) +#else if(::close(mSocketHandle) == -1) +#endif { THROW_EXCEPTION(ServerException, SocketCloseError) } @@ -128,8 +137,12 @@ public: } // Set an option to allow reuse (useful for -HUP situations!) +#ifdef WIN32 + if(::setsockopt(mSocketHandle, SOL_SOCKET, SO_REUSEADDR, "", 0) == -1) +#else int option = true; if(::setsockopt(mSocketHandle, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option)) == -1) +#endif { THROW_EXCEPTION(ServerException, SocketOpenError) } |