@@ -386,6 +386,12 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest)
386386 if (pszDest ? ConnectSocketByName (addrConnect, hSocket, pszDest, Params ().GetDefaultPort (), nConnectTimeout, &proxyConnectionFailed) :
387387 ConnectSocket (addrConnect, hSocket, nConnectTimeout, &proxyConnectionFailed))
388388 {
389+ if (!IsSelectableSocket (hSocket)) {
390+ LogPrintf (" Cannot create connection: non-selectable socket created (fd >= FD_SETSIZE ?)\n " );
391+ CloseSocket (hSocket);
392+ return NULL ;
393+ }
394+
389395 addrman.Attempt (addrConnect);
390396
391397 // Add node
@@ -949,6 +955,11 @@ void ThreadSocketHandler()
949955 if (nErr != WSAEWOULDBLOCK)
950956 LogPrintf (" socket error accept failed: %s\n " , NetworkErrorString (nErr));
951957 }
958+ else if (!IsSelectableSocket (hSocket))
959+ {
960+ LogPrintf (" connection from %s dropped: non-selectable socket\n " , addr.ToString ());
961+ CloseSocket (hSocket);
962+ }
952963 else if (nInbound >= nMaxInbound)
953964 {
954965 LogPrint (" net" , " connection from %s dropped (full)\n " , addr.ToString ());
@@ -1597,6 +1608,13 @@ bool BindListenPort(const CService &addrBind, string& strError, bool fWhiteliste
15971608 LogPrintf (" %s\n " , strError);
15981609 return false ;
15991610 }
1611+ if (!IsSelectableSocket (hListenSocket))
1612+ {
1613+ strError = " Error: Couldn't create a listenable socket for incoming connections" ;
1614+ LogPrintf (" %s\n " , strError);
1615+ return false ;
1616+ }
1617+
16001618
16011619#ifndef WIN32
16021620#ifdef SO_NOSIGPIPE
0 commit comments