Let TCPConnection.leastSize time out according to the readTimeout property.

Fixes #153.
This commit is contained in:
Sönke Ludwig 2019-06-16 09:55:00 +02:00
parent 1d917568e5
commit 0d78dfe4a9

View file

@ -553,7 +553,18 @@ struct TCPConnection {
return s >= ConnectionState.connected && s < ConnectionState.activeClose; return s >= ConnectionState.connected && s < ConnectionState.activeClose;
} }
@property bool empty() { return leastSize == 0; } @property bool empty() { return leastSize == 0; }
@property ulong leastSize() { waitForData(); return m_context ? m_context.readBuffer.length : 0; }
@property ulong leastSize()
{
if (!m_context) return 0;
auto res = waitForDataEx(m_context.readTimeout);
if (res == WaitForDataStatus.timeout)
throw new ReadTimeoutException("Read operation timed out");
return m_context.readBuffer.length;
}
@property bool dataAvailableForRead() { return waitForData(0.seconds); } @property bool dataAvailableForRead() { return waitForData(0.seconds); }
void close() void close()