summary refs log tree commit diff stats
path: root/lib/pure/includes/asynccommon.nim
diff options
context:
space:
mode:
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) =