diff options
author | Gampol T <gampolt@gmail.com> | 2019-10-09 15:48:15 +0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-10-09 10:48:15 +0200 |
commit | 82fe19769ab7c796b82110c05e1a6b2d77648971 (patch) | |
tree | 55232a4f628654476fb8739af4f007ead8ff0146 | |
parent | 84c956d9dadfac0fa149dbc1eb7adef6888c95dc (diff) | |
download | Nim-82fe19769ab7c796b82110c05e1a6b2d77648971.tar.gz |
documented behaviour of recv on bufferd socket (#12374)
-rw-r--r-- | lib/pure/net.nim | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/pure/net.nim b/lib/pure/net.nim index 9f8c8bc5a..878665690 100644 --- a/lib/pure/net.nim +++ b/lib/pure/net.nim @@ -1143,6 +1143,15 @@ proc recv*(socket: Socket, data: var string, size: int, timeout = -1, flags = {SocketFlag.SafeDisconn}): int = ## Higher-level version of ``recv``. ## + ## Reads **up to** ``size`` bytes from ``socket`` into ``buf``. + ## + ## For buffered sockets this function will attempt to read all the requested + ## data. It will read this data in ``BufferSize`` chunks. + ## + ## For unbuffered sockets this function makes no effort to read + ## all the data requested. It will return as much data as the operating system + ## gives it. + ## ## When 0 is returned the socket's connection has been closed. ## ## This function will throw an OSError exception when an error occurs. A value @@ -1171,6 +1180,15 @@ proc recv*(socket: Socket, size: int, timeout = -1, flags = {SocketFlag.SafeDisconn}): string {.inline.} = ## Higher-level version of ``recv`` which returns a string. ## + ## Reads **up to** ``size`` bytes from ``socket`` into ``buf``. + ## + ## For buffered sockets this function will attempt to read all the requested + ## data. It will read this data in ``BufferSize`` chunks. + ## + ## For unbuffered sockets this function makes no effort to read + ## all the data requested. It will return as much data as the operating system + ## gives it. + ## ## When ``""`` is returned the socket's connection has been closed. ## ## This function will throw an OSError exception when an error occurs. |