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/includes | |
parent | d24b6667c6f74b61ea697bf91ce454f297ddac91 (diff) | |
download | Nim-1a2351f95fa1ddef0eb824426af355d079ed37cd.tar.gz |
Fixes #4995. (#7157)
Diffstat (limited to 'lib/pure/includes')
-rw-r--r-- | lib/pure/includes/asynccommon.nim | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/pure/includes/asynccommon.nim b/lib/pure/includes/asynccommon.nim index 8b760c66a..45b10c584 100644 --- a/lib/pure/includes/asynccommon.nim +++ b/lib/pure/includes/asynccommon.nim @@ -1,21 +1,31 @@ -template newAsyncNativeSocketImpl(domain, sockType, protocol) = +template createAsyncNativeSocketImpl(domain, sockType, protocol) = let handle = newNativeSocket(domain, sockType, protocol) if handle == osInvalidSocket: - raiseOSError(osLastError()) + return osInvalidSocket.AsyncFD handle.setBlocking(false) when defined(macosx) and not defined(nimdoc): handle.setSockOptInt(SOL_SOCKET, SO_NOSIGPIPE, 1) result = handle.AsyncFD register(result) -proc newAsyncNativeSocket*(domain: cint, sockType: cint, +proc createAsyncNativeSocket*(domain: cint, sockType: cint, protocol: cint): AsyncFD = - newAsyncNativeSocketImpl(domain, sockType, protocol) + createAsyncNativeSocketImpl(domain, sockType, protocol) -proc newAsyncNativeSocket*(domain: Domain = Domain.AF_INET, +proc createAsyncNativeSocket*(domain: Domain = Domain.AF_INET, sockType: SockType = SOCK_STREAM, protocol: Protocol = IPPROTO_TCP): AsyncFD = - newAsyncNativeSocketImpl(domain, sockType, protocol) + createAsyncNativeSocketImpl(domain, sockType, protocol) + +proc newAsyncNativeSocket*(domain: cint, sockType: cint, + protocol: cint): AsyncFD {.deprecated.} = + createAsyncNativeSocketImpl(domain, sockType, protocol) + +proc newAsyncNativeSocket*(domain: Domain = Domain.AF_INET, + sockType: SockType = SOCK_STREAM, + protocol: Protocol = IPPROTO_TCP): AsyncFD + {.deprecated.} = + createAsyncNativeSocketImpl(domain, sockType, protocol) when defined(windows) or defined(nimdoc): proc bindToDomain(handle: SocketHandle, domain: Domain) = |