diff options
author | David <david@xagasoft.com> | 2009-01-14 21:15:16 +0000 |
---|---|---|
committer | David <david@xagasoft.com> | 2009-01-14 21:15:16 +0000 |
commit | a10b1fd0b76fab720d2430315da7ac80776204e6 (patch) | |
tree | 44cf3d777f4daa3948a6dd00395a43c58e041da6 /src/socket.cpp | |
parent | ef2f33c700a9f559648089a5314638f9c73d3589 (diff) | |
download | libbu++-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 '')
-rw-r--r-- | src/socket.cpp | 41 |
1 files changed, 11 insertions, 30 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 ) : | |||
44 | Bu::Socket::Socket( const Bu::FString &sAddr, int nPort, int nTimeout ) | 44 | Bu::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 | ||
162 | Bu::Socket::~Socket() | 143 | Bu::Socket::~Socket() |