From c2292209eb4ece185f555a5c7823726794fe34cc Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 29 Jul 2009 19:01:02 +0000 Subject: Wow, socket, as it turned out, was not able to close after the remote end disconnected. It now automatically closes down the local end when the remote end dies. --- src/server.cpp | 1 + src/socket.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server.cpp b/src/server.cpp index b7dec41..bfa7880 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -92,6 +92,7 @@ void Bu::Server::scan() if( !pClient->isOpen() ) { onClosedConnection( pClient ); + pClient->close(); hClients.erase( j ); FD_CLR( j, &fdActive ); } diff --git a/src/socket.cpp b/src/socket.cpp index 46e6cd7..3ddc492 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -159,7 +159,7 @@ size_t Bu::Socket::read( void *pBuf, size_t nBytes ) bu_recv( nSocket, (char *) pBuf, nBytes, 0 ) ); if( nRead == 0 ) { - bActive = false; + close(); throw SocketException( SocketException::cClosed, "Socket closed."); } if( nRead < 0 ) @@ -171,7 +171,7 @@ size_t Bu::Socket::read( void *pBuf, size_t nBytes ) #else if( errno == ENETRESET || errno == ECONNRESET ) { - bActive = false; + close(); throw SocketException( SocketException::cClosed, strerror(errno) ); } -- cgit v1.2.3