0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-27 08:41:02 +08:00

Check if receive return zero - set it to disconnect

This commit is contained in:
Sergey Yagovtsev 2016-09-18 18:33:10 +03:00
parent d2b4423c7b
commit 9b7b80febe
2 changed files with 12 additions and 0 deletions

View File

@ -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;

View File

@ -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)
{