From a10b1fd0b76fab720d2430315da7ac80776204e6 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 14 Jan 2009 21:15:16 +0000 Subject: david - removed debugging goo after finally getting it to work --- src/socket.cpp | 41 +++++++++++------------------------------ src/win32_compatibility.cpp | 10 ---------- src/win32_compatibility.h | 2 +- 3 files changed, 12 insertions(+), 41 deletions(-) diff --git a/src/socket.cpp b/src/socket.cpp index 3458b45..1c53ec8 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -36,7 +36,7 @@ Bu::Socket::Socket( int nSocket ) : bActive( true ) { #ifdef WIN32 - DynamicWinsock32::Winsock2::getInstance(); + DynamicWinsock2::Winsock2::getInstance(); #endif setAddress(); } @@ -44,10 +44,10 @@ Bu::Socket::Socket( int nSocket ) : Bu::Socket::Socket( const Bu::FString &sAddr, int nPort, int nTimeout ) { #ifdef WIN32 - DynamicWinsock32::Winsock2::getInstance(); + DynamicWinsock2::Winsock2::getInstance(); #endif bActive = false; - + /* Create the socket. */ nSocket = DYNLOAD socket( PF_INET, SOCK_STREAM, 0 ); @@ -88,35 +88,17 @@ Bu::Socket::Socket( const Bu::FString &sAddr, int nPort, int nTimeout ) char ibuf[10]; sprintf( ibuf, "%d", nPort ); - if( int ret = DYNLOAD getaddrinfo( sAddr.getStr(), ibuf, &aiHints, &pAddr ) + int ret; + if( ret = DYNLOAD getaddrinfo( sAddr.getStr(), ibuf, &aiHints, &pAddr ) != 0 ) { - - struct addrinfo *pCur = pAddr; - while( pCur ) - { - printf("Name: %s\n", pCur->ai_canonname ); - printf(" Flags: %d\n", pCur->ai_flags ); - printf(" Family: %d\n", pCur->ai_family ); - printf(" Socktype: %d\n", pCur->ai_socktype ); - printf(" Protocol: %d\n", pCur->ai_protocol ); - - pCur = pCur->ai_next; - } + #ifdef WIN32 + throw Bu::SocketException("Couldn't resolve hostname %s (%d).\n", + sAddr.getStr(), DYNLOAD WSAGetLastError()); + #else throw Bu::SocketException("Couldn't resolve hostname %s (%s).\n", - sAddr.getStr(), gai_strerror(ret)); - } - - struct addrinfo *pCur = pAddr; - while( pCur ) - { - printf("Name: %s\n", pCur->ai_canonname ); - printf(" Flags: %d\n", pCur->ai_flags ); - printf(" Family: %d\n", pCur->ai_family ); - printf(" Socktype: %d\n", pCur->ai_socktype ); - printf(" Protocol: %d\n", pCur->ai_protocol ); - - pCur = pCur->ai_next; + sAddr.getStr(), DYNLOAD gai_strerror(ret)); + #endif } DYNLOAD connect( @@ -156,7 +138,6 @@ Bu::Socket::Socket( const Bu::FString &sAddr, int nPort, int nTimeout ) throw ExceptionBase("Connection timeout.\n"); } } - setAddress(); } Bu::Socket::~Socket() diff --git a/src/win32_compatibility.cpp b/src/win32_compatibility.cpp index e7710e5..54fd56c 100644 --- a/src/win32_compatibility.cpp +++ b/src/win32_compatibility.cpp @@ -8,12 +8,10 @@ int DynamicWinsock2::WSAStartup( { int out=0; HINSTANCE Ws2_32 = LoadLibrary(TEXT("WS2_32.DLL")); - printf("ws2_32 dll: %08x\n", (int) Ws2_32); if( Ws2_32 != NULL ) { FNDEF_DYN_WSAStartup fn = (FNDEF_DYN_WSAStartup) GetProcAddress( Ws2_32, "WSAStartup" ); - printf("WSAStartup function pointer: %08x\n", (int)fn); if( fn != NULL ) out = (fn)(wVersionRequested,lpWSAData); } @@ -25,12 +23,10 @@ int DynamicWinsock2::WSACleanup() { int out=0; HINSTANCE Ws2_32 = LoadLibrary(TEXT("WS2_32.DLL")); - printf("ws2_32 dll: %08x\n", (int) Ws2_32); if( Ws2_32 != NULL ) { FNDEF_DYN_WSACleanup fn = (FNDEF_DYN_WSACleanup) GetProcAddress( Ws2_32, "WSACleanup" ); - printf("WSACleanup function pointer: %08x\n", (int)fn); if( fn != NULL ) out = (fn)(); } @@ -43,12 +39,10 @@ int DynamicWinsock2::WSAGetLastError() { int out=0; HINSTANCE Ws2_32 = LoadLibrary(TEXT("WS2_32.DLL")); - printf("ws2_32 dll: %08x\n", (int) Ws2_32); if( Ws2_32 != NULL ) { FNDEF_DYN_WSAGetLastError fn = (FNDEF_DYN_WSAGetLastError) GetProcAddress( Ws2_32, "WSAGetLastError" ); - printf("WSAGetLastError function pointer: %08x\n", (int)fn); if( fn != NULL ) out = (fn)(); } @@ -106,19 +100,15 @@ int DynamicWinsock2::select(int nfds, fd_set *readfds, fd_set *writefds, typedef SOCKET (__cdecl *FNDEF_DYN_socket)(int,int,int); SOCKET DynamicWinsock2::socket(int domain, int type, int protocol) { - printf("in win32::socket\n"); SOCKET out = 0; HINSTANCE Ws2_32 = LoadLibrary(TEXT("Ws2_32")); - printf("ws2_32 dll: %08x\n", (int) Ws2_32); if( Ws2_32 != NULL ) { FNDEF_DYN_socket fn = (FNDEF_DYN_socket) GetProcAddress( Ws2_32, "socket" ); - printf("socket function pointer: %08x\n", (int)fn); if( fn != NULL ) out = (fn)( domain, type, protocol ); } - printf("win32::socket complete.\n"); return out; } diff --git a/src/win32_compatibility.h b/src/win32_compatibility.h index 2fe740a..2d3c52b 100644 --- a/src/win32_compatibility.h +++ b/src/win32_compatibility.h @@ -77,7 +77,7 @@ namespace DynamicWinsock2 WSADATA wsaData; public: - } + }; }; #endif /* WIN32 */ -- cgit v1.2.3