Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Copy up to a specified number of bytes received from a remote socket into an application memory buffer.

Files

net_sock.h/net_sock.c
net_bsd.h/net_bsd.c

Prototypes

 

 

Arguments

sock_id

This is the socket ID returned by NetSock_Open()/socket() when the socket was created or by NetSock_Accept()/accept() when a connection was accepted.

...

NET_SOCK_ERR_NONE
NET_ERR_FAULT_NULL_PTR
NET_SOCK_ERR_NULL_SIZE
NET_SOCK_ERR_NOT_USED
NET_SOCK_ERR_CLOSED
NET_SOCK_ERR_INVALID_SOCK
NET_SOCK_ERR_INVALID_FAMILY
NET_SOCK_ERR_INVALID_PROTOCOL
NET_SOCK_ERR_INVALID_TYPE
NET_SOCK_ERR_INVALID_STATE
NET_SOCK_ERR_INVALID_OP
NET_SOCK_ERR_INVALID_FLAG
NET_SOCK_ERR_INVALID_ADDR_LEN
NET_SOCK_ERR_INVALID_DATA_SIZE
NET_SOCK_ERR_CONN_FAIL
NET_SOCK_ERR_FAULT
NET_SOCK_ERR_RX_Q_EMPTY
NET_SOCK_ERR_RX_Q_CLOSED
NET_ERR_RX
NET_CONN_ERR_NOT_USED
NET_CONN_ERR_INVALID_CONN
NET_CONN_ERR_INVALID_ADDR_LEN
NET_CONN_ERR_ADDR_NOT_USED
NET_INIT_ERR_NOT_COMPLETED
NET_ERR_FAULT_LOCK_ACQUIRE

Returned Value

Positive number of bytes received, if successful;

...

NET_SOCK_BSD_ERR_RX/-1, otherwise.

Blocking vs Non-Blocking

The default setting for µC/TCP-IP is blocking. However, this setting can be changed at compile time by setting the NET_SOCK_DFLT_NO_BLOCK_EN to DEF_ENABLED or DEF_DISABLED.  (see net_cfg.h file).

...

The current version of µC/TCP-IP selects blocking or non-blocking at compile time for all sockets. A future version may allow the selection of blocking or non-blocking at the individual socket level. However, each socket receive call can pass the NET_SOCK_FLAG_RX_NO_BLOCK/MSG_DONTWAIT flag to disable blocking on that call.

Required Configuration

None.

Notes / Warnings

TCP sockets typically use NetSock_RxData()/recv(), whereas UDP sockets typically use NetSock_RxDataFrom()/recvfrom().

...