summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid <david@xagasoft.com>2009-01-14 21:15:16 +0000
committerDavid <david@xagasoft.com>2009-01-14 21:15:16 +0000
commita10b1fd0b76fab720d2430315da7ac80776204e6 (patch)
tree44cf3d777f4daa3948a6dd00395a43c58e041da6 /src
parentef2f33c700a9f559648089a5314638f9c73d3589 (diff)
downloadlibbu++-a10b1fd0b76fab720d2430315da7ac80776204e6.tar.gz
libbu++-a10b1fd0b76fab720d2430315da7ac80776204e6.tar.bz2
libbu++-a10b1fd0b76fab720d2430315da7ac80776204e6.tar.xz
libbu++-a10b1fd0b76fab720d2430315da7ac80776204e6.zip
david - removed debugging goo after finally getting it to work
Diffstat (limited to 'src')
-rw-r--r--src/socket.cpp41
-rw-r--r--src/win32_compatibility.cpp10
-rw-r--r--src/win32_compatibility.h2
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 ) :
36 bActive( true ) 36 bActive( true )
37{ 37{
38#ifdef WIN32 38#ifdef WIN32
39 DynamicWinsock32::Winsock2::getInstance(); 39 DynamicWinsock2::Winsock2::getInstance();
40#endif 40#endif
41 setAddress(); 41 setAddress();
42} 42}
@@ -44,10 +44,10 @@ Bu::Socket::Socket( int nSocket ) :
44Bu::Socket::Socket( const Bu::FString &sAddr, int nPort, int nTimeout ) 44Bu::Socket::Socket( const Bu::FString &sAddr, int nPort, int nTimeout )
45{ 45{
46#ifdef WIN32 46#ifdef WIN32
47 DynamicWinsock32::Winsock2::getInstance(); 47 DynamicWinsock2::Winsock2::getInstance();
48#endif 48#endif
49 bActive = false; 49 bActive = false;
50 50
51 /* Create the socket. */ 51 /* Create the socket. */
52 nSocket = DYNLOAD socket( PF_INET, SOCK_STREAM, 0 ); 52 nSocket = DYNLOAD socket( PF_INET, SOCK_STREAM, 0 );
53 53
@@ -88,35 +88,17 @@ Bu::Socket::Socket( const Bu::FString &sAddr, int nPort, int nTimeout )
88 char ibuf[10]; 88 char ibuf[10];
89 sprintf( ibuf, "%d", nPort ); 89 sprintf( ibuf, "%d", nPort );
90 90
91 if( int ret = DYNLOAD getaddrinfo( sAddr.getStr(), ibuf, &aiHints, &pAddr ) 91 int ret;
92 if( ret = DYNLOAD getaddrinfo( sAddr.getStr(), ibuf, &aiHints, &pAddr )
92 != 0 ) 93 != 0 )
93 { 94 {
94 95 #ifdef WIN32
95 struct addrinfo *pCur = pAddr; 96 throw Bu::SocketException("Couldn't resolve hostname %s (%d).\n",
96 while( pCur ) 97 sAddr.getStr(), DYNLOAD WSAGetLastError());
97 { 98 #else
98 printf("Name: %s\n", pCur->ai_canonname );
99 printf(" Flags: %d\n", pCur->ai_flags );
100 printf(" Family: %d\n", pCur->ai_family );
101 printf(" Socktype: %d\n", pCur->ai_socktype );
102 printf(" Protocol: %d\n", pCur->ai_protocol );
103
104 pCur = pCur->ai_next;
105 }
106 throw Bu::SocketException("Couldn't resolve hostname %s (%s).\n", 99 throw Bu::SocketException("Couldn't resolve hostname %s (%s).\n",
107 sAddr.getStr(), gai_strerror(ret)); 100 sAddr.getStr(), DYNLOAD gai_strerror(ret));
108 } 101 #endif
109
110 struct addrinfo *pCur = pAddr;
111 while( pCur )
112 {
113 printf("Name: %s\n", pCur->ai_canonname );
114 printf(" Flags: %d\n", pCur->ai_flags );
115 printf(" Family: %d\n", pCur->ai_family );
116 printf(" Socktype: %d\n", pCur->ai_socktype );
117 printf(" Protocol: %d\n", pCur->ai_protocol );
118
119 pCur = pCur->ai_next;
120 } 102 }
121 103
122 DYNLOAD connect( 104 DYNLOAD connect(
@@ -156,7 +138,6 @@ Bu::Socket::Socket( const Bu::FString &sAddr, int nPort, int nTimeout )
156 throw ExceptionBase("Connection timeout.\n"); 138 throw ExceptionBase("Connection timeout.\n");
157 } 139 }
158 } 140 }
159 setAddress();
160} 141}
161 142
162Bu::Socket::~Socket() 143Bu::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(
8{ 8{
9 int out=0; 9 int out=0;
10 HINSTANCE Ws2_32 = LoadLibrary(TEXT("WS2_32.DLL")); 10 HINSTANCE Ws2_32 = LoadLibrary(TEXT("WS2_32.DLL"));
11 printf("ws2_32 dll: %08x\n", (int) Ws2_32);
12 if( Ws2_32 != NULL ) 11 if( Ws2_32 != NULL )
13 { 12 {
14 FNDEF_DYN_WSAStartup fn = (FNDEF_DYN_WSAStartup) 13 FNDEF_DYN_WSAStartup fn = (FNDEF_DYN_WSAStartup)
15 GetProcAddress( Ws2_32, "WSAStartup" ); 14 GetProcAddress( Ws2_32, "WSAStartup" );
16 printf("WSAStartup function pointer: %08x\n", (int)fn);
17 if( fn != NULL ) 15 if( fn != NULL )
18 out = (fn)(wVersionRequested,lpWSAData); 16 out = (fn)(wVersionRequested,lpWSAData);
19 } 17 }
@@ -25,12 +23,10 @@ int DynamicWinsock2::WSACleanup()
25{ 23{
26 int out=0; 24 int out=0;
27 HINSTANCE Ws2_32 = LoadLibrary(TEXT("WS2_32.DLL")); 25 HINSTANCE Ws2_32 = LoadLibrary(TEXT("WS2_32.DLL"));
28 printf("ws2_32 dll: %08x\n", (int) Ws2_32);
29 if( Ws2_32 != NULL ) 26 if( Ws2_32 != NULL )
30 { 27 {
31 FNDEF_DYN_WSACleanup fn = (FNDEF_DYN_WSACleanup) 28 FNDEF_DYN_WSACleanup fn = (FNDEF_DYN_WSACleanup)
32 GetProcAddress( Ws2_32, "WSACleanup" ); 29 GetProcAddress( Ws2_32, "WSACleanup" );
33 printf("WSACleanup function pointer: %08x\n", (int)fn);
34 if( fn != NULL ) 30 if( fn != NULL )
35 out = (fn)(); 31 out = (fn)();
36 } 32 }
@@ -43,12 +39,10 @@ int DynamicWinsock2::WSAGetLastError()
43{ 39{
44 int out=0; 40 int out=0;
45 HINSTANCE Ws2_32 = LoadLibrary(TEXT("WS2_32.DLL")); 41 HINSTANCE Ws2_32 = LoadLibrary(TEXT("WS2_32.DLL"));
46 printf("ws2_32 dll: %08x\n", (int) Ws2_32);
47 if( Ws2_32 != NULL ) 42 if( Ws2_32 != NULL )
48 { 43 {
49 FNDEF_DYN_WSAGetLastError fn = (FNDEF_DYN_WSAGetLastError) 44 FNDEF_DYN_WSAGetLastError fn = (FNDEF_DYN_WSAGetLastError)
50 GetProcAddress( Ws2_32, "WSAGetLastError" ); 45 GetProcAddress( Ws2_32, "WSAGetLastError" );
51 printf("WSAGetLastError function pointer: %08x\n", (int)fn);
52 if( fn != NULL ) 46 if( fn != NULL )
53 out = (fn)(); 47 out = (fn)();
54 } 48 }
@@ -106,19 +100,15 @@ int DynamicWinsock2::select(int nfds, fd_set *readfds, fd_set *writefds,
106typedef SOCKET (__cdecl *FNDEF_DYN_socket)(int,int,int); 100typedef SOCKET (__cdecl *FNDEF_DYN_socket)(int,int,int);
107SOCKET DynamicWinsock2::socket(int domain, int type, int protocol) 101SOCKET DynamicWinsock2::socket(int domain, int type, int protocol)
108{ 102{
109 printf("in win32::socket\n");
110 SOCKET out = 0; 103 SOCKET out = 0;
111 HINSTANCE Ws2_32 = LoadLibrary(TEXT("Ws2_32")); 104 HINSTANCE Ws2_32 = LoadLibrary(TEXT("Ws2_32"));
112 printf("ws2_32 dll: %08x\n", (int) Ws2_32);
113 if( Ws2_32 != NULL ) 105 if( Ws2_32 != NULL )
114 { 106 {
115 FNDEF_DYN_socket fn = (FNDEF_DYN_socket) 107 FNDEF_DYN_socket fn = (FNDEF_DYN_socket)
116 GetProcAddress( Ws2_32, "socket" ); 108 GetProcAddress( Ws2_32, "socket" );
117 printf("socket function pointer: %08x\n", (int)fn);
118 if( fn != NULL ) 109 if( fn != NULL )
119 out = (fn)( domain, type, protocol ); 110 out = (fn)( domain, type, protocol );
120 } 111 }
121 printf("win32::socket complete.\n");
122 return out; 112 return out;
123} 113}
124 114
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
77 WSADATA wsaData; 77 WSADATA wsaData;
78 78
79 public: 79 public:
80 } 80 };
81}; 81};
82 82
83#endif /* WIN32 */ 83#endif /* WIN32 */