diff options
Diffstat (limited to '')
-rw-r--r-- | src/connection.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/connection.cpp b/src/connection.cpp index 0dff918..cb3c724 100644 --- a/src/connection.cpp +++ b/src/connection.cpp | |||
@@ -161,6 +161,7 @@ bool Connection::open( const char *sAddr, int nPort ) | |||
161 | 161 | ||
162 | /* Create the socket. */ | 162 | /* Create the socket. */ |
163 | nSocket = socket( PF_INET, SOCK_STREAM, 0 ); | 163 | nSocket = socket( PF_INET, SOCK_STREAM, 0 ); |
164 | |||
164 | if( nSocket < 0 ) | 165 | if( nSocket < 0 ) |
165 | { | 166 | { |
166 | bActive = false; | 167 | bActive = false; |
@@ -240,7 +241,7 @@ int Connection::readInput() | |||
240 | 241 | ||
241 | bool Connection::readInput( int nSec, int nUSec, int *pnSecBack, int *pnUSecBack ) | 242 | bool Connection::readInput( int nSec, int nUSec, int *pnSecBack, int *pnUSecBack ) |
242 | { | 243 | { |
243 | fd_set rfds; | 244 | fd_set rfds, efds; |
244 | struct timeval tv, start, end; | 245 | struct timeval tv, start, end; |
245 | struct timezone tz; | 246 | struct timezone tz; |
246 | int retval; | 247 | int retval; |
@@ -249,6 +250,8 @@ bool Connection::readInput( int nSec, int nUSec, int *pnSecBack, int *pnUSecBack | |||
249 | 250 | ||
250 | FD_ZERO(&rfds); | 251 | FD_ZERO(&rfds); |
251 | FD_SET(nSocket, &rfds); | 252 | FD_SET(nSocket, &rfds); |
253 | FD_ZERO(&efds); | ||
254 | FD_SET(nSocket, &efds); | ||
252 | 255 | ||
253 | tv.tv_sec = nSec; | 256 | tv.tv_sec = nSec; |
254 | tv.tv_usec = nUSec; | 257 | tv.tv_usec = nUSec; |
@@ -266,10 +269,11 @@ bool Connection::readInput( int nSec, int nUSec, int *pnSecBack, int *pnUSecBack | |||
266 | { | 269 | { |
267 | //printf("retval=%d, nSocket=%d,%d, sec=%d, usec=%d\n", retval, nSocket, FD_ISSET( nSocket, &rfds ), tv.tv_sec, tv.tv_usec ); | 270 | //printf("retval=%d, nSocket=%d,%d, sec=%d, usec=%d\n", retval, nSocket, FD_ISSET( nSocket, &rfds ), tv.tv_sec, tv.tv_usec ); |
268 | // None of them have data, but the connection is still active. | 271 | // None of them have data, but the connection is still active. |
269 | if( readInput() == 0 ) | 272 | if( FD_ISSET( nSocket, &rfds ) ) |
270 | { | 273 | { |
271 | this->close(); | 274 | if( readInput() == 0 ) |
272 | throw ConnectionException( excodeConnectionClosed, "Connection closed"); | 275 | { |
276 | throw ConnectionException( excodeConnectionClosed, "Connection closed"); } | ||
273 | } | 277 | } |
274 | } | 278 | } |
275 | 279 | ||