From 862d6ad2346b08fef0e28fbcf289edcad5461af4 Mon Sep 17 00:00:00 2001 From: Anatoly Galiulin Date: Wed, 31 Aug 2016 14:18:39 +0700 Subject: [PATCH] Restore ``recvInto`` for backwards compatibility --- lib/pure/asyncdispatch.nim | 12 ++++++++++++ lib/upcoming/asyncdispatch.nim | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim index faac79d3b3..49926b0191 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 1f66ef6c8a..96392c4178 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