diff options
author | Dominik Picheta <dominikpicheta@gmail.com> | 2018-02-17 19:36:06 +0000 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@gmail.com> | 2018-02-17 19:36:06 +0000 |
commit | 63bc046ddf2a2ff6694d0a3757ef28ec4ca7b5f3 (patch) | |
tree | c838b68c79465a7b2efadc37e400131ee690fa5f | |
parent | 5476a82c47413d78b09e07abd07ba78d1d560dc3 (diff) | |
download | Nim-63bc046ddf2a2ff6694d0a3757ef28ec4ca7b5f3.tar.gz |
Fixes #7227.
-rw-r--r-- | lib/pure/net.nim | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/pure/net.nim b/lib/pure/net.nim index ba964c39e..99d868847 100644 --- a/lib/pure/net.nim +++ b/lib/pure/net.nim @@ -64,6 +64,9 @@ ## socket.acceptAddr(client, address) ## echo("Client connected from: ", address) ## +## **Note:** The ``client`` variable is initialised with ``new Socket`` **not** +## ``newSocket()``. The difference is that the latter creates a new file +## descriptor. {.deadCodeElim: on.} import nativesockets, os, strutils, parseutils, times, sets, options @@ -753,6 +756,8 @@ proc acceptAddr*(server: Socket, client: var Socket, address: var string, ## flag is specified then this error will not be raised and instead ## accept will be called again. assert(client != nil) + assert client.fd.int <= 0, "Client socket needs to be initialised with " & + "`new`, not `newSocket`." let ret = accept(server.fd) let sock = ret[0] |