diff --git a/other/tcpserver_main.cpp b/other/tcpserver_main.cpp index a24ae0c..06b6172 100644 --- a/other/tcpserver_main.cpp +++ b/other/tcpserver_main.cpp @@ -49,7 +49,8 @@ int main( int argc, char * argv[] ) tcpServer.start(); - sleep(10); + // never reached + sleep(1); tcpServer.stop(); diff --git a/src/TcpClient.cpp b/src/TcpClient.cpp index e56cdfc..cd2fc7e 100644 --- a/src/TcpClient.cpp +++ b/src/TcpClient.cpp @@ -59,6 +59,7 @@ bool TcpClient::send(const std::string msg) ssize_t n = write(m_socket, msg.c_str(), msg.length()); if (n == -1) { LOG( Logger::ERR, errnoToString("ERROR writing to socket. ").c_str() ); + m_watcher.stopPolling(); return false; } @@ -88,6 +89,7 @@ void TcpClient::WatcherThread::handleClient( const int fd ) TRACE; LOG( Logger::DEBUG, "Server closed the connection." ); + stopPolling(); } @@ -105,6 +107,7 @@ bool TcpClient::WatcherThread::receive( const int fd) if (len == 0) { LOG( Logger::DEBUG, "Connection closed by peer." ); + stopPolling(); return false; }