summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-08-04 12:10:36 +0200
committerAttila Molnar <attilamolnar@hush.com>2014-08-04 12:10:36 +0200
commite17db7c63a53cb834e2cc8d221d759bdf2c2b69b (patch)
treec4a30770eb48c1a8f16adf69b808872c09beaf70
parentcd1d8b7f0f4922bc35a5ca3974993f0106431fc8 (diff)
threadengine_win32 Use a stripped-down, local version of InspIRCd::BindSocket() for setting up the ITC pipe
-rw-r--r--src/threadengines/threadengine_win32.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/threadengines/threadengine_win32.cpp b/src/threadengines/threadengine_win32.cpp
index 90fe60b91..0f0d1f277 100644
--- a/src/threadengines/threadengine_win32.cpp
+++ b/src/threadengines/threadengine_win32.cpp
@@ -70,6 +70,24 @@ class ThreadSignalSocket : public BufferedSocket
}
};
+static bool BindAndListen(int sockfd, int port, const char* addr)
+{
+ irc::sockets::sockaddrs servaddr;
+ if (!irc::sockets::aptosa(addr, port, servaddr))
+ return false;
+
+ if (SocketEngine::Bind(sockfd, servaddr) != 0)
+ return false;
+
+ if (SocketEngine::Listen(sockfd, ServerInstance->Config->MaxConn) != 0)
+ {
+ ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR in listen(): %s", strerror(errno));
+ return false;
+ }
+
+ return true;
+}
+
SocketThread::SocketThread()
{
int listenFD = socket(AF_INET, SOCK_STREAM, 0);
@@ -79,7 +97,7 @@ SocketThread::SocketThread()
if (connFD == -1)
throw CoreException("Could not create ITC pipe");
- if (!ServerInstance->BindSocket(listenFD, 0, "127.0.0.1", true))
+ if (!BindAndListen(listenFD, 0, "127.0.0.1"))
throw CoreException("Could not create ITC pipe");
SocketEngine::NonBlocking(connFD);