@@ -178,7 +178,7 @@ bool RecvLine(SOCKET hSocket, string& strLine)
178
178
{
179
179
// socket error
180
180
int nErr = WSAGetLastError ();
181
- LogPrint (" net" , " recv failed: %d \n " , nErr);
181
+ LogPrint (" net" , " recv failed: %s \n " , NetworkErrorString ( nErr) );
182
182
return false ;
183
183
}
184
184
}
@@ -489,10 +489,10 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest)
489
489
#ifdef WIN32
490
490
u_long nOne = 1 ;
491
491
if (ioctlsocket (hSocket, FIONBIO, &nOne) == SOCKET_ERROR)
492
- LogPrintf (" ConnectSocket() : ioctlsocket non-blocking setting failed, error %d \n " , WSAGetLastError ());
492
+ LogPrintf (" ConnectSocket() : ioctlsocket non-blocking setting failed, error %s \n " , NetworkErrorString ( WSAGetLastError () ));
493
493
#else
494
494
if (fcntl (hSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR)
495
- LogPrintf (" ConnectSocket() : fcntl non-blocking setting failed, error %d \n " , errno);
495
+ LogPrintf (" ConnectSocket() : fcntl non-blocking setting failed, error %s \n " , NetworkErrorString ( errno) );
496
496
#endif
497
497
498
498
// Add node
@@ -736,7 +736,7 @@ void SocketSendData(CNode *pnode)
736
736
int nErr = WSAGetLastError ();
737
737
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
738
738
{
739
- LogPrintf (" socket send error %d \n " , nErr);
739
+ LogPrintf (" socket send error %s \n " , NetworkErrorString ( nErr) );
740
740
pnode->CloseSocketDisconnect ();
741
741
}
742
742
}
@@ -896,7 +896,7 @@ void ThreadSocketHandler()
896
896
if (have_fds)
897
897
{
898
898
int nErr = WSAGetLastError ();
899
- LogPrintf (" socket select error %d \n " , nErr);
899
+ LogPrintf (" socket select error %s \n " , NetworkErrorString ( nErr) );
900
900
for (unsigned int i = 0 ; i <= hSocketMax; i++)
901
901
FD_SET (i, &fdsetRecv);
902
902
}
@@ -933,7 +933,7 @@ void ThreadSocketHandler()
933
933
{
934
934
int nErr = WSAGetLastError ();
935
935
if (nErr != WSAEWOULDBLOCK)
936
- LogPrintf (" socket error accept failed: %d \n " , nErr);
936
+ LogPrintf (" socket error accept failed: %s \n " , NetworkErrorString ( nErr) );
937
937
}
938
938
else if (nInbound >= nMaxConnections - MAX_OUTBOUND_CONNECTIONS)
939
939
{
@@ -1007,7 +1007,7 @@ void ThreadSocketHandler()
1007
1007
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
1008
1008
{
1009
1009
if (!pnode->fDisconnect )
1010
- LogPrintf (" socket recv error %d \n " , nErr);
1010
+ LogPrintf (" socket recv error %s \n " , NetworkErrorString ( nErr) );
1011
1011
pnode->CloseSocketDisconnect ();
1012
1012
}
1013
1013
}
@@ -1585,7 +1585,7 @@ bool BindListenPort(const CService &addrBind, string& strError)
1585
1585
SOCKET hListenSocket = socket (((struct sockaddr *)&sockaddr)->sa_family , SOCK_STREAM, IPPROTO_TCP);
1586
1586
if (hListenSocket == INVALID_SOCKET)
1587
1587
{
1588
- strError = strprintf (" Error: Couldn't open socket for incoming connections (socket returned error %d )" , WSAGetLastError ());
1588
+ strError = strprintf (" Error: Couldn't open socket for incoming connections (socket returned error %s )" , NetworkErrorString ( WSAGetLastError () ));
1589
1589
LogPrintf (" %s\n " , strError);
1590
1590
return false ;
1591
1591
}
@@ -1609,7 +1609,7 @@ bool BindListenPort(const CService &addrBind, string& strError)
1609
1609
if (fcntl (hListenSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR)
1610
1610
#endif
1611
1611
{
1612
- strError = strprintf (" Error: Couldn't set properties on socket for incoming connections (error %d )" , WSAGetLastError ());
1612
+ strError = strprintf (" Error: Couldn't set properties on socket for incoming connections (error %s )" , NetworkErrorString ( WSAGetLastError () ));
1613
1613
LogPrintf (" %s\n " , strError);
1614
1614
return false ;
1615
1615
}
@@ -1638,7 +1638,7 @@ bool BindListenPort(const CService &addrBind, string& strError)
1638
1638
if (nErr == WSAEADDRINUSE)
1639
1639
strError = strprintf (_ (" Unable to bind to %s on this computer. Bitcoin Core is probably already running." ), addrBind.ToString ());
1640
1640
else
1641
- strError = strprintf (_ (" Unable to bind to %s on this computer (bind returned error %d, % s)" ), addrBind.ToString (), nErr, strerror (nErr));
1641
+ strError = strprintf (_ (" Unable to bind to %s on this computer (bind returned error %s)" ), addrBind.ToString (), NetworkErrorString (nErr));
1642
1642
LogPrintf (" %s\n " , strError);
1643
1643
return false ;
1644
1644
}
@@ -1647,7 +1647,7 @@ bool BindListenPort(const CService &addrBind, string& strError)
1647
1647
// Listen for incoming connections
1648
1648
if (listen (hListenSocket, SOMAXCONN) == SOCKET_ERROR)
1649
1649
{
1650
- strError = strprintf (_ (" Error: Listening for incoming connections failed (listen returned error %d )" ), WSAGetLastError ());
1650
+ strError = strprintf (_ (" Error: Listening for incoming connections failed (listen returned error %s )" ), NetworkErrorString ( WSAGetLastError () ));
1651
1651
LogPrintf (" %s\n " , strError);
1652
1652
return false ;
1653
1653
}
@@ -1785,7 +1785,7 @@ class CNetCleanup
1785
1785
BOOST_FOREACH (SOCKET hListenSocket, vhListenSocket)
1786
1786
if (hListenSocket != INVALID_SOCKET)
1787
1787
if (closesocket (hListenSocket) == SOCKET_ERROR)
1788
- LogPrintf (" closesocket(hListenSocket) failed with error %d \n " , WSAGetLastError ());
1788
+ LogPrintf (" closesocket(hListenSocket) failed with error %s \n " , NetworkErrorString ( WSAGetLastError () ));
1789
1789
1790
1790
// clean up some globals (to help leak detection)
1791
1791
BOOST_FOREACH (CNode *pnode, vNodes)
0 commit comments