0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-28 01:04:41 +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]; char *buf = &buffer[seek];
if(bytes == 0){
isListen = false;
continue;
}
if (bytes > 0) if (bytes > 0)
{ {
profiler::net::Message* message = (profiler::net::Message*)buf; 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; if(m_replySocket <= 0) return -1;
int res = ::read(m_replySocket,buf,nbyte); int res = ::read(m_replySocket,buf,nbyte);
checkResult(res); checkResult(res);
if (res == 0){
m_state = CONNECTION_STATE_DISCONNECTED;
}
return res; return res;
} }
@ -242,6 +245,10 @@ int EasySocket::receive(void *buf, size_t nbyte)
int res = ::recv(m_replySocket, (char*)buf, nbyte, 0); int res = ::recv(m_replySocket, (char*)buf, nbyte, 0);
checkResult(res); checkResult(res);
if (res == 0){
m_state = CONNECTION_STATE_DISCONNECTED;
}
/** /**
if (res == SOCKET_ERROR) if (res == SOCKET_ERROR)
{ {