summary refs log tree commit diff stats
path: root/lib/pure/includes/asynccommon.nim
diff options
context:
space:
mode:
authorDaniil Yarancev <21169548+Yardanico@users.noreply.github.com>2018-06-05 21:25:45 +0300
committerGitHub <noreply@github.com>2018-06-05 21:25:45 +0300
commit642641359821b6a63c6cf7edaaa45873b7ea59c7 (patch)
tree627af3020528cb916b3174bd94304307ca875c77 /lib/pure/includes/asynccommon.nim
parentfb44c522e6173528efa8035ecc459c84887d0167 (diff)
parent3cbc07ac7877b03c605498760fe198e3200cc197 (diff)
downloadNim-642641359821b6a63c6cf7edaaa45873b7ea59c7.tar.gz
Merge pull request #2 from nim-lang/devel
Update
Diffstat (limited to 'lib/pure/includes/asynccommon.nim')
-rw-r--r--lib/pure/includes/asynccommon.nim22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/pure/includes/asynccommon.nim b/lib/pure/includes/asynccommon.nim
index 8b760c66a..06f4958c6 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: "use createAsyncNativeSocket instead".} =
+  createAsyncNativeSocketImpl(domain, sockType, protocol)
+
+proc newAsyncNativeSocket*(domain: Domain = Domain.AF_INET,
+                           sockType: SockType = SOCK_STREAM,
+                           protocol: Protocol = IPPROTO_TCP): AsyncFD
+                           {.deprecated: "use createAsyncNativeSocket instead".} =
+  createAsyncNativeSocketImpl(domain, sockType, protocol)
 
 when defined(windows) or defined(nimdoc):
   proc bindToDomain(handle: SocketHandle, domain: Domain) =