summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2018-03-29 11:35:03 +0100
committerGitHub <noreply@github.com>2018-03-29 11:35:03 +0100
commita429afaa21edaa1b7eceedff13a85ff1b1610fd7 (patch)
treeb4cbe93c694da8fc4a5d0216e5cf32d2143648a8
parentbcda71a8a7c05566d729cf83f051dbc51649f6d5 (diff)
parentace96bf83e711438d517bec33e5d83f27e352726 (diff)
downloadNim-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.nim3
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)