]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/threadengines/threadengine_win32.cpp
Update copyright headers.
[user/henk/code/inspircd.git] / src / threadengines / threadengine_win32.cpp
index 90fe60b91e8ebd58c0ae0395bc7fc9d78ead3be7..b14f46e8e7d004413be9c4403e51ea91490da5ff 100644 (file)
@@ -1,8 +1,13 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- *   Copyright (C) 2008 Craig Edwards <craigedwards@brainbox.cc>
+ *   Copyright (C) 2013-2014 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2012 ChrisTX <xpipe@hotmail.de>
+ *   Copyright (C) 2009, 2011 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
+ *   Copyright (C) 2009 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2008-2009 Craig Edwards <brain@inspircd.org>
  *
  * 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);