From 4181e1940d9abaa8d39f247262db5c88322108c9 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Thu, 11 Jan 2018 20:46:44 +0000 Subject: [PATCH] recv with a timeout of -1 shouldn't wait on all data. --- lib/pure/net.nim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pure/net.nim b/lib/pure/net.nim index 083e70c8da..9215a18128 100644 --- a/lib/pure/net.nim +++ b/lib/pure/net.nim @@ -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)