From 1cc86e79e843ac78e127b22f51e215ec32d7d791 Mon Sep 17 00:00:00 2001 From: Toon Schoenmakers Date: Fri, 6 Nov 2015 15:17:41 +0100 Subject: [PATCH] fix detection of connections that are closed by the server --- src/tcpbuffer.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tcpbuffer.h b/src/tcpbuffer.h index 492e376..17c034c 100644 --- a/src/tcpbuffer.h +++ b/src/tcpbuffer.h @@ -376,8 +376,9 @@ public: // when the buffer is very small, we use a lower limit of 512 bytes if (ioctl(socket, FIONREAD, &available) != 0) return -1; - // no need to read anything if there is no input - if (available == 0) return 0; + // if no bytes are available, it could mean that the connection was closed + // by the remote client, so we do have to call read() anyway, assume a default buffer + if (available == 0) available = 1; // add a new buffer _buffers.emplace_back(available);