From 301ca6c81dd572e5f10b081d5f37e9d9683dd2d5 Mon Sep 17 00:00:00 2001 From: Christian Ulrich Date: Tue, 21 Jul 2020 10:17:36 +0200 Subject: [PATCH] sometimes recvLine returns "\r\n" when the peer disconnects (not documented). Handle that as a disconnect. --- examples/rendezvous_server/rendezvous_server.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/rendezvous_server/rendezvous_server.nim b/examples/rendezvous_server/rendezvous_server.nim index ac25bb7..4e56def 100644 --- a/examples/rendezvous_server/rendezvous_server.nim +++ b/examples/rendezvous_server/rendezvous_server.nim @@ -34,7 +34,8 @@ proc processClient(client: AsyncSocket, clients: TableRef[string, Client]) {.asy var id = "" var peerId = "" while true: - let line = await client.recvLine(maxLength = 400) + var line = await client.recvLine(maxLength = 400) + line = line.strip(leading = false, trailing = true, chars = {'\r', '\n'}) if line.len == 0: removeClient(clients, peerId) break