X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fthreadengines%2Fthreadengine_win32.cpp;h=b14f46e8e7d004413be9c4403e51ea91490da5ff;hb=f3f2388a81b6463e1229fa5bf2b8c427440bf406;hp=90fe60b91e8ebd58c0ae0395bc7fc9d78ead3be7;hpb=fd7ea0cedf528095cc887bd164b0ff8b2edb2f43;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/threadengines/threadengine_win32.cpp b/src/threadengines/threadengine_win32.cpp index 90fe60b91..b14f46e8e 100644 --- a/src/threadengines/threadengine_win32.cpp +++ b/src/threadengines/threadengine_win32.cpp @@ -1,8 +1,13 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2009 Daniel De Graaf - * Copyright (C) 2008 Craig Edwards + * Copyright (C) 2013-2014 Attila Molnar + * Copyright (C) 2012 Robby + * Copyright (C) 2012 ChrisTX + * Copyright (C) 2009, 2011 Daniel De Graaf + * Copyright (C) 2009 Uli Schlachter + * Copyright (C) 2009 Dennis Friis + * Copyright (C) 2008-2009 Craig Edwards * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -70,6 +75,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 +102,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);