diff options
author | Anatoly Galiulin <galiulin.anatoly@gmail.com> | 2016-08-31 14:18:39 +0700 |
---|---|---|
committer | Anatoly Galiulin <galiulin.anatoly@gmail.com> | 2016-09-06 09:31:13 +0700 |
commit | 862d6ad2346b08fef0e28fbcf289edcad5461af4 (patch) | |
tree | da5ad124974f3a8c3473cbe9a7eb1a1cec4571d6 | |
parent | 436a5a01ab9c2baa13e68d87de26e3e7ecc125aa (diff) | |
download | Nim-862d6ad2346b08fef0e28fbcf289edcad5461af4.tar.gz |
Restore ``recvInto`` for backwards compatibility
-rw-r--r-- | lib/pure/asyncdispatch.nim | 12 | ||||
-rw-r--r-- | lib/upcoming/asyncdispatch.nim | 12 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim index faac79d3b..49926b019 100644 --- a/lib/pure/asyncdispatch.nim +++ b/lib/pure/asyncdispatch.nim @@ -816,6 +816,18 @@ when defined(windows) or defined(nimdoc): retFuture.complete(bytesReceived) return retFuture + proc recvInto*(socket: AsyncFD, buf: cstring, size: int, + flags = {SocketFlag.SafeDisconn}): Future[int] = + ## Reads **up to** ``size`` bytes from ``socket`` into ``buf``, which must + ## at least be of that size. Returned future will complete once all the + ## data requested is read, a part of the data has been read, or the socket + ## has disconnected in which case the future will complete with a value of + ## ``0``. + ## + ## **Warning**: The ``Peek`` socket flag is not supported on Windows. + + socket.recvBuffer(buf, size, flags) + proc sendBuffer*(socket: AsyncFD, buf: pointer, size: int, flags = {SocketFlag.SafeDisconn}): Future[void] = ## Sends ``size`` bytes from ``buf`` to ``socket``. The returned future will complete once all diff --git a/lib/upcoming/asyncdispatch.nim b/lib/upcoming/asyncdispatch.nim index 1f66ef6c8..96392c417 100644 --- a/lib/upcoming/asyncdispatch.nim +++ b/lib/upcoming/asyncdispatch.nim @@ -785,6 +785,18 @@ when defined(windows) or defined(nimdoc): retFuture.complete(bytesReceived) return retFuture + proc recvInto*(socket: AsyncFD, buf: cstring, size: int, + flags = {SocketFlag.SafeDisconn}): Future[int] = + ## Reads **up to** ``size`` bytes from ``socket`` into ``buf``, which must + ## at least be of that size. Returned future will complete once all the + ## data requested is read, a part of the data has been read, or the socket + ## has disconnected in which case the future will complete with a value of + ## ``0``. + ## + ## **Warning**: The ``Peek`` socket flag is not supported on Windows. + + socket.recvBuffer(buf, size, flags) + proc sendBuffer*(socket: AsyncFD, buf: pointer, size: int, flags = {SocketFlag.SafeDisconn}): Future[void] = ## Sends ``size`` bytes from ``buf`` to ``socket``. The returned future will complete once all |