libfreerdp-core/tcp: check for peer disconnection.

This commit is contained in:
Vic Lee 2011-08-18 23:14:46 +08:00
parent 5fc87c25cf
commit 9d414132e4

View File

@ -155,12 +155,14 @@ int tcp_read(rdpTcp* tcp, uint8* data, int length)
status = recv(tcp->sockfd, data, length, 0);
if (status < 0)
if (status <= 0)
{
/* No data available */
if (errno == EAGAIN || errno == EWOULDBLOCK)
return 0;
perror("recv");
/* When peer disconnects we get status 0 with no error. */
if (status < 0)
perror("recv");
return -1;
}