X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fnet.cpp;h=ead7362616887e9c9b35df1adb9c6fa1fe3f3e4d;hb=6853e627f12de21b38a178def14c067435517d96;hp=0e861236df45fcba18dd4a5be23937b1abc39f97;hpb=e9b95e4f6c35cb0f150ff7e70154668f142ee0ba;p=novacoin.git diff --git a/src/net.cpp b/src/net.cpp index 0e86123..ead7362 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -10,7 +10,7 @@ #include "init.h" #include "strlcpy.h" -#ifdef __WXMSW__ +#ifdef WIN32 #include #endif @@ -102,7 +102,7 @@ bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout bool fProxy = (fUseProxy && addrConnect.IsRoutable()); struct sockaddr_in sockaddr = (fProxy ? addrProxy.GetSockAddr() : addrConnect.GetSockAddr()); -#ifdef __WXMSW__ +#ifdef WIN32 u_long fNonblock = 1; if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR) #else @@ -141,7 +141,7 @@ bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout return false; } socklen_t nRetSize = sizeof(nRet); -#ifdef __WXMSW__ +#ifdef WIN32 if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, (char*)(&nRet), &nRetSize) == SOCKET_ERROR) #else if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR) @@ -158,7 +158,7 @@ bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout return false; } } -#ifdef __WXMSW__ +#ifdef WIN32 else if (WSAGetLastError() != WSAEISCONN) #else else @@ -175,7 +175,7 @@ bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout CNode::ConnectNode immediately turns the socket back to non-blocking but we'll turn it back to blocking just in case */ -#ifdef __WXMSW__ +#ifdef WIN32 fNonblock = 0; if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR) #else @@ -674,7 +674,7 @@ CNode* ConnectNode(CAddress addrConnect, int64 nTimeout) printf("connected %s\n", addrConnect.ToString().c_str()); // Set to nonblocking -#ifdef __WXMSW__ +#ifdef WIN32 u_long nOne = 1; if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) printf("ConnectSocket() : ioctlsocket nonblocking setting failed, error %d\n", WSAGetLastError()); @@ -1612,7 +1612,7 @@ bool BindListenPort(string& strError) int nOne = 1; addrLocalHost.port = htons(GetListenPort()); -#ifdef __WXMSW__ +#ifdef WIN32 // Initialize Windows Sockets WSADATA wsadata; int ret = WSAStartup(MAKEWORD(2,2), &wsadata); @@ -1638,13 +1638,13 @@ bool BindListenPort(string& strError) setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int)); #endif -#ifndef __WXMSW__ +#ifndef WIN32 // Allow binding if the port is still in TIME_WAIT state after // the program was closed and restarted. Not an issue on windows. setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int)); #endif -#ifdef __WXMSW__ +#ifdef WIN32 // Set to nonblocking, incoming connections will also inherit this if (ioctlsocket(hListenSocket, FIONBIO, (u_long*)&nOne) == SOCKET_ERROR) #else @@ -1691,7 +1691,7 @@ void StartNode(void* parg) if (pnodeLocalHost == NULL) pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress("127.0.0.1", 0, false, nLocalServices)); -#ifdef __WXMSW__ +#ifdef WIN32 // Get local host ip char pszHostName[1000] = ""; if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR) @@ -1827,7 +1827,7 @@ public: if (closesocket(hListenSocket) == SOCKET_ERROR) printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError()); -#ifdef __WXMSW__ +#ifdef WIN32 // Shutdown Windows Sockets WSACleanup(); #endif