diff options
author | boopcat <actually.boop@gmail.com> | 2015-05-30 11:01:15 +0000 |
---|---|---|
committer | boopcat <actually.boop@gmail.com> | 2015-05-30 11:01:15 +0000 |
commit | af07db28297e0d4d03a1c1e64da524b0119d62fe (patch) | |
tree | 999a2979f5fe8208c3f5796078135dfaf4085467 | |
parent | 6820b2fea919c033405e7e204343fddd947c2ef3 (diff) | |
download | Nim-af07db28297e0d4d03a1c1e64da524b0119d62fe.tar.gz |
Export newSocket(fd) from net.nim and standardize args in net/asyncnet
Exporting newSocket(fd) mimics what asyncnet does and lets you pass in your own socket FD. newSocket*(fd) and newAsyncSocket*(fd) now both take "buffered" instead of "isBuff" and defaults to true to match the other constructors on both.
-rw-r--r-- | lib/pure/asyncnet.nim | 6 | ||||
-rw-r--r-- | lib/pure/net.nim | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim index aadbde824..e759f9788 100644 --- a/lib/pure/asyncnet.nim +++ b/lib/pure/asyncnet.nim @@ -91,13 +91,13 @@ type # TODO: Save AF, domain etc info and reuse it in procs which need it like connect. -proc newAsyncSocket*(fd: TAsyncFD, isBuff: bool): AsyncSocket = +proc newAsyncSocket*(fd: TAsyncFD, buffered = true): AsyncSocket = ## Creates a new ``AsyncSocket`` based on the supplied params. assert fd != osInvalidSocket.TAsyncFD new(result) result.fd = fd.SocketHandle - result.isBuffered = isBuff - if isBuff: + result.isBuffered = buffered + if buffered: result.currPos = 0 proc newAsyncSocket*(domain: Domain = AF_INET, typ: SockType = SOCK_STREAM, diff --git a/lib/pure/net.nim b/lib/pure/net.nim index cf37c271e..1990818e5 100644 --- a/lib/pure/net.nim +++ b/lib/pure/net.nim @@ -118,13 +118,13 @@ proc toOSFlags*(socketFlags: set[SocketFlag]): cint = result = result or MSG_PEEK 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. assert fd != osInvalidSocket new(result) result.fd = fd - result.isBuffered = isBuff - if isBuff: + result.isBuffered = buffered + if buffered: result.currPos = 0 proc newSocket*(domain, typ, protocol: cint, buffered = true): Socket = |