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