summaryrefslogtreecommitdiff
path: root/lib/server/SocketListen.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/server/SocketListen.h')
-rwxr-xr-xlib/server/SocketListen.h21
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)
}