diff --git a/profiler_gui/main_window.cpp b/profiler_gui/main_window.cpp index a03e218..a94491b 100644 --- a/profiler_gui/main_window.cpp +++ b/profiler_gui/main_window.cpp @@ -361,6 +361,11 @@ void EasyMainWindow::listen() char *buf = &buffer[seek]; + if(bytes == 0){ + isListen = false; + continue; + } + if (bytes > 0) { profiler::net::Message* message = (profiler::net::Message*)buf; diff --git a/src/easy_socket.cpp b/src/easy_socket.cpp index c2243e1..691e56f 100644 --- a/src/easy_socket.cpp +++ b/src/easy_socket.cpp @@ -73,6 +73,9 @@ int EasySocket::receive(void *buf, size_t nbyte) if(m_replySocket <= 0) return -1; int res = ::read(m_replySocket,buf,nbyte); checkResult(res); + if (res == 0){ + m_state = CONNECTION_STATE_DISCONNECTED; + } return res; } @@ -242,6 +245,10 @@ int EasySocket::receive(void *buf, size_t nbyte) int res = ::recv(m_replySocket, (char*)buf, nbyte, 0); checkResult(res); + if (res == 0){ + m_state = CONNECTION_STATE_DISCONNECTED; + } + /** if (res == SOCKET_ERROR) {