Merge branch 'exportnewsocket' of https://github.com/boopcat/Nim into boopcat-exportnewsocket
Conflicts: lib/pure/asyncnet.nim
This commit is contained in:
commit
c5708ef1ee
2 changed files with 6 additions and 6 deletions
|
|
@ -91,13 +91,13 @@ type
|
||||||
|
|
||||||
# TODO: Save AF, domain etc info and reuse it in procs which need it like connect.
|
# TODO: Save AF, domain etc info and reuse it in procs which need it like connect.
|
||||||
|
|
||||||
proc newAsyncSocket*(fd: AsyncFD, isBuff: bool): AsyncSocket =
|
proc newAsyncSocket*(fd: AsyncFD, buffered = true): AsyncSocket =
|
||||||
## Creates a new ``AsyncSocket`` based on the supplied params.
|
## Creates a new ``AsyncSocket`` based on the supplied params.
|
||||||
assert fd != osInvalidSocket.AsyncFD
|
assert fd != osInvalidSocket.AsyncFD
|
||||||
new(result)
|
new(result)
|
||||||
result.fd = fd.SocketHandle
|
result.fd = fd.SocketHandle
|
||||||
result.isBuffered = isBuff
|
result.isBuffered = buffered
|
||||||
if isBuff:
|
if buffered:
|
||||||
result.currPos = 0
|
result.currPos = 0
|
||||||
|
|
||||||
proc newAsyncSocket*(domain: Domain = AF_INET, typ: SockType = SOCK_STREAM,
|
proc newAsyncSocket*(domain: Domain = AF_INET, typ: SockType = SOCK_STREAM,
|
||||||
|
|
|
||||||
|
|
@ -119,13 +119,13 @@ proc toOSFlags*(socketFlags: set[SocketFlag]): cint =
|
||||||
result = result or MSG_PEEK
|
result = result or MSG_PEEK
|
||||||
of SocketFlag.SafeDisconn: continue
|
of SocketFlag.SafeDisconn: continue
|
||||||
|
|
||||||
proc newSocket(fd: SocketHandle, isBuff: bool): Socket =
|
proc newSocket*(fd: SocketHandle, buffered = true): Socket =
|
||||||
## Creates a new socket as specified by the params.
|
## Creates a new socket as specified by the params.
|
||||||
assert fd != osInvalidSocket
|
assert fd != osInvalidSocket
|
||||||
new(result)
|
new(result)
|
||||||
result.fd = fd
|
result.fd = fd
|
||||||
result.isBuffered = isBuff
|
result.isBuffered = buffered
|
||||||
if isBuff:
|
if buffered:
|
||||||
result.currPos = 0
|
result.currPos = 0
|
||||||
|
|
||||||
proc newSocket*(domain, typ, protocol: cint, buffered = true): Socket =
|
proc newSocket*(domain, typ, protocol: cint, buffered = true): Socket =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue