recv with a timeout of -1 shouldn't wait on all data.

This commit is contained in:
Dominik Picheta
2018-01-11 20:46:44 +00:00
parent 72d9485e8e
commit 4181e1940d

View File

@@ -1145,7 +1145,11 @@ proc recv*(socket: Socket, data: var string, size: int, timeout = -1,
##
## **Warning**: Only the ``SafeDisconn`` flag is currently supported.
data.setLen(size)
result = recv(socket, cstring(data), size, timeout)
result =
if timeout == -1:
recv(socket, cstring(data), size)
else:
recv(socket, cstring(data), size, timeout)
if result < 0:
data.setLen(0)
let lastError = getSocketError(socket)