Report IP addresses while logging failed connections
[novacoin.git] / src / netbase.cpp
index 95d6493..42e08db 100644 (file)
@@ -3,8 +3,8 @@
 // Distributed under the MIT/X11 software license, see the accompanying
 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
 
-#include "netbase.h"
 #include "util.h"
+#include "netbase.h"
 #include "sync.h"
 
 #ifndef WIN32
@@ -368,13 +368,13 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
             int nRet = select(hSocket + 1, NULL, &fdset, NULL, &timeout);
             if (nRet == 0)
             {
-                printf("connection timeout\n");
+                printf("connection to %s timeout\n", addrConnect.ToString().c_str());
                 closesocket(hSocket);
                 return false;
             }
             if (nRet == SOCKET_ERROR)
             {
-                printf("select() for connection failed: %i\n",WSAGetLastError());
+                printf("select() for %s failed: %i\n", addrConnect.ToString().c_str(), WSAGetLastError());
                 closesocket(hSocket);
                 return false;
             }
@@ -385,13 +385,13 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
             if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR)
 #endif
             {
-                printf("getsockopt() for connection failed: %i\n",WSAGetLastError());
+                printf("getsockopt() for %s failed: %i\n", addrConnect.ToString().c_str(), WSAGetLastError());
                 closesocket(hSocket);
                 return false;
             }
             if (nRet != 0)
             {
-                printf("connect() failed after select(): %s\n",strerror(nRet));
+                printf("connect() to %s failed after select(): %s\n", addrConnect.ToString().c_str(), strerror(nRet));
                 closesocket(hSocket);
                 return false;
             }
@@ -402,7 +402,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
         else
 #endif
         {
-            printf("connect() failed: %i\n",WSAGetLastError());
+            printf("connect() to %s failed: %i\n", addrConnect.ToString().c_str(), WSAGetLastError());
             closesocket(hSocket);
             return false;
         }