diff options
author | Dominik Picheta <dominikpicheta@googlemail.com> | 2018-02-13 10:08:37 +0000 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-02-13 11:08:37 +0100 |
commit | 1a2351f95fa1ddef0eb824426af355d079ed37cd (patch) | |
tree | 4f47201d784757276a8ac2c76020661a74e5896b /lib/pure/asyncnet.nim | |
parent | d24b6667c6f74b61ea697bf91ce454f297ddac91 (diff) | |
download | Nim-1a2351f95fa1ddef0eb824426af355d079ed37cd.tar.gz |
Fixes #4995. (#7157)
Diffstat (limited to 'lib/pure/asyncnet.nim')
-rw-r--r-- | lib/pure/asyncnet.nim | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim index bdbf47004..a75f9daac 100644 --- a/lib/pure/asyncnet.nim +++ b/lib/pure/asyncnet.nim @@ -163,8 +163,10 @@ proc newAsyncSocket*(domain: Domain = AF_INET, sockType: SockType = SOCK_STREAM, ## ## This procedure will also create a brand new file descriptor for ## this socket. - result = newAsyncSocket(newAsyncNativeSocket(domain, sockType, protocol), - domain, sockType, protocol, buffered) + let fd = createAsyncNativeSocket(domain, sockType, protocol) + if fd.SocketHandle == osInvalidSocket: + raiseOSError(osLastError()) + result = newAsyncSocket(fd, domain, sockType, protocol, buffered) proc newAsyncSocket*(domain, sockType, protocol: cint, buffered = true): AsyncSocket = @@ -172,8 +174,10 @@ proc newAsyncSocket*(domain, sockType, protocol: cint, ## ## This procedure will also create a brand new file descriptor for ## this socket. - result = newAsyncSocket(newAsyncNativeSocket(domain, sockType, protocol), - Domain(domain), SockType(sockType), + let fd = createAsyncNativeSocket(domain, sockType, protocol) + if fd.SocketHandle == osInvalidSocket: + raiseOSError(osLastError()) + result = newAsyncSocket(fd, Domain(domain), SockType(sockType), Protocol(protocol), buffered) when defineSsl: |