fixing problems with detecting a disconnected client

This commit is contained in:
Igor Socec 2014-03-13 11:02:19 +01:00
parent 496198f488
commit be121ac22f
2 changed files with 15 additions and 14 deletions

View file

@ -23,6 +23,11 @@ int client_read(struct client_t *client) {
fprintf(stderr, "[%s:%d] error %d: %s\n", __func__, __LINE__, errno, strerror(errno));
return -errno;
}
/* a disconnected client socket is ready for reading but read returns 0 */
if (len == 0) {
fprintf(stderr, "[%s:%d] no data available from client\n", __func__, __LINE__);
return -ENODATA; //TODO document this in header
}
//TODO let's print received bytes during development phase...
{