Skip to content

Commit 6bf0611

Browse files
author
Seppo Takalo
committed
Clarify TCPSocket::recv() and UDPSocket::recvfrom() documentation.
1 parent 70e7b40 commit 6bf0611

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

features/netsocket/TCPSocket.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ class TCPSocket : public Socket {
111111
* @param data Destination buffer for data received from the host
112112
* @param size Size of the buffer in bytes
113113
* @return Number of received bytes on success, negative error
114-
* code on failure
114+
* code on failure. If no data is available to be received
115+
* and the peer has performed an orderly shutdown,
116+
* recv() returns 0.
115117
*/
116118
nsapi_size_or_error_t recv(void *data, nsapi_size_t size);
117119

features/netsocket/UDPSocket.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,18 @@ class UDPSocket : public Socket {
9494
nsapi_size_or_error_t sendto(const SocketAddress &address,
9595
const void *data, nsapi_size_t size);
9696

97-
/** Receive a packet over a UDP socket
97+
/** Receive a datagram over a UDP socket
9898
*
99-
* Receives data and stores the source address in address if address
100-
* is not NULL. Returns the number of bytes received into the buffer.
99+
* Receives a datagram and stores the source address in address if address
100+
* is not NULL. Returns the number of bytes written into the buffer. If the
101+
* datagram is larger than the buffer, the excess data is silently discarded.
101102
*
102-
* By default, recvfrom blocks until data is sent. If socket is set to
103-
* non-blocking or times out, NSAPI_ERROR_WOULD_BLOCK is returned
104-
* immediately.
103+
* By default, recvfrom blocks until a datagram is received. If socket is set to
104+
* non-blocking or times out with no datagram, NSAPI_ERROR_WOULD_BLOCK
105+
* is returned.
105106
*
106107
* @param address Destination for the source address or NULL
107-
* @param data Destination buffer for data received from the host
108+
* @param data Destination buffer for datagram received from the host
108109
* @param size Size of the buffer in bytes
109110
* @return Number of received bytes on success, negative error
110111
* code on failure

0 commit comments

Comments
 (0)