Browse Source

Improve logging of failed connections

0.10
Gavin Andresen 11 years ago
parent
commit
0f90613cbe
  1. 10
      src/netbase.cpp

10
src/netbase.cpp

@ -367,13 +367,13 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
int nRet = select(hSocket + 1, NULL, &fdset, NULL, &timeout); int nRet = select(hSocket + 1, NULL, &fdset, NULL, &timeout);
if (nRet == 0) if (nRet == 0)
{ {
LogPrint("net", "connection timeout\n"); LogPrint("net", "connection to %s timeout\n", addrConnect.ToString().c_str());
closesocket(hSocket); closesocket(hSocket);
return false; return false;
} }
if (nRet == SOCKET_ERROR) if (nRet == SOCKET_ERROR)
{ {
LogPrintf("select() for connection failed: %i\n",WSAGetLastError()); LogPrintf("select() for %s failed: %i\n", addrConnect.ToString().c_str(), WSAGetLastError());
closesocket(hSocket); closesocket(hSocket);
return false; return false;
} }
@ -384,13 +384,13 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR) if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR)
#endif #endif
{ {
LogPrintf("getsockopt() for connection failed: %i\n",WSAGetLastError()); LogPrintf("getsockopt() for %s failed: %i\n", addrConnect.ToString().c_str(), WSAGetLastError());
closesocket(hSocket); closesocket(hSocket);
return false; return false;
} }
if (nRet != 0) if (nRet != 0)
{ {
LogPrintf("connect() failed after select(): %s\n",strerror(nRet)); LogPrintf("connect() to %s failed after select(): %s\n", addrConnect.ToString().c_str(), strerror(nRet));
closesocket(hSocket); closesocket(hSocket);
return false; return false;
} }
@ -401,7 +401,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
else else
#endif #endif
{ {
LogPrintf("connect() failed: %i\n",WSAGetLastError()); LogPrintf("connect() to %s failed: %i\n", addrConnect.ToString().c_str(), WSAGetLastError());
closesocket(hSocket); closesocket(hSocket);
return false; return false;
} }

Loading…
Cancel
Save