diff options
author | Dominik Picheta <dominikpicheta@gmail.com> | 2018-01-11 20:47:07 +0000 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@gmail.com> | 2018-01-15 17:48:32 +0000 |
commit | 1661062ebf147e55e29a0bfb8fc62dc7959b8614 (patch) | |
tree | 3e5e4ff17b9e31f1d41a439feeedb07d5bea61cc /lib/pure/asyncnet.nim | |
parent | 4181e1940d9abaa8d39f247262db5c88322108c9 (diff) | |
download | Nim-1661062ebf147e55e29a0bfb8fc62dc7959b8614.tar.gz |
Raise assertion error when attempting to use closed socket.
Diffstat (limited to 'lib/pure/asyncnet.nim')
-rw-r--r-- | lib/pure/asyncnet.nim | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim index 5be457d2a..93399bb40 100644 --- a/lib/pure/asyncnet.nim +++ b/lib/pure/asyncnet.nim @@ -277,6 +277,7 @@ template readInto(buf: pointer, size: int, socket: AsyncSocket, flags: set[SocketFlag]): int = ## Reads **up to** ``size`` bytes from ``socket`` into ``buf``. Note that ## this is a template and not a proc. + assert(not socket.closed, "Cannot `recv` on a closed socket") var res = 0 if socket.isSsl: when defineSsl: @@ -403,6 +404,7 @@ proc send*(socket: AsyncSocket, buf: pointer, size: int, ## Sends ``size`` bytes from ``buf`` to ``socket``. The returned future will complete once all ## data has been sent. assert socket != nil + assert(not socket.closed, "Cannot `send` on a closed socket") if socket.isSsl: when defineSsl: sslLoop(socket, flags, |