Adds socket creation for arbitrary domain, type and protocol.

This commit is contained in:
Dominik Picheta 2014-09-18 17:01:44 +01:00
commit 867dfbfbfa
4 changed files with 31 additions and 0 deletions

View file

@ -766,6 +766,12 @@ when defined(windows) or defined(nimdoc):
return retFuture
proc newAsyncRawSocket*(domain, typ, protocol: cint): TAsyncFD =
## Creates a new socket and registers it with the dispatcher implicitly.
result = newRawSocket(domain, typ, protocol).TAsyncFD
result.SocketHandle.setBlocking(false)
register(result)
proc newAsyncRawSocket*(domain: Domain = AF_INET,
typ: SockType = SOCK_STREAM,
protocol: Protocol = IPPROTO_TCP): TAsyncFD =
@ -832,6 +838,11 @@ else:
var data = PData(sock: sock, readCBs: @[], writeCBs: @[])
p.selector.register(sock.SocketHandle, {}, data.PObject)
proc newAsyncRawSocket*(domain: cint, typ: cint, protocol: cint): TAsyncFD =
result = newRawSocket(domain, typ, protocol).TAsyncFD
result.SocketHandle.setBlocking(false)
register(result)
proc newAsyncRawSocket*(domain: TDomain = AF_INET,
typ: TType = SOCK_STREAM,
protocol: TProtocol = IPPROTO_TCP): TAsyncFD =