diff options
author | Dominik Picheta <dominikpicheta@googlemail.com> | 2018-03-29 11:35:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-29 11:35:03 +0100 |
commit | a429afaa21edaa1b7eceedff13a85ff1b1610fd7 (patch) | |
tree | b4cbe93c694da8fc4a5d0216e5cf32d2143648a8 | |
parent | bcda71a8a7c05566d729cf83f051dbc51649f6d5 (diff) | |
parent | ace96bf83e711438d517bec33e5d83f27e352726 (diff) | |
download | Nim-a429afaa21edaa1b7eceedff13a85ff1b1610fd7.tar.gz |
Merge pull request #7436 from gmfawcett/fawcett-net-connect-error
net.connect (with timeout), raise error on connect failure
-rw-r--r-- | lib/pure/net.nim | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/pure/net.nim b/lib/pure/net.nim index af9eea51a..2d1ca8a59 100644 --- a/lib/pure/net.nim +++ b/lib/pure/net.nim @@ -1664,6 +1664,9 @@ proc connect*(socket: Socket, address: string, port = Port(0), if selectWrite(s, timeout) != 1: raise newException(TimeoutError, "Call to 'connect' timed out.") else: + let res = getSockOptInt(socket.fd, SOL_SOCKET, SO_ERROR) + if res != 0: + raiseOSError(OSErrorCode(res)) when defineSsl and not defined(nimdoc): if socket.isSSL: socket.fd.setBlocking(true) |