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. See function NetSock_RxData() for more information.

Files

net_bsd.h/net_bsd.c

Prototypes

Code Block
ssize_t  recv (int      sock_id,
               void    *p_data_buf,
              _size_t   data_buf_len,
               int      flags);

 
ssize_t  recvfrom (         int         sock_id,
                            void       *p_data_buf,
                           _size_t      data_buf_len,
                            int         flags,
                   struct   sockaddr   *p_addr_remote,
                            socklen_t  *p_addr_len);

Arguments

sock_id

Socket descriptor/handle identifier of socket to receive data.

p_data_buf

Pointer to an application data buffer that will receive the socket's received data.

data_buf_len

Size of the application data buffer (in octets).

flags

Flags to select receive options; bit-field flags logically OR'd:

0, No socket flags selected.

MSG_PEEK, Receive socket data without consuming the socket data.

MSG_DONTWAIT, Receive socket data without blocking.

p_addr_remote

Pointer to an address buffer that will receive the socket address structure with the received data's remote address, if no error(s).

p_addr_len

Pointer to a variable to:

    1. Pass the size of the address buffer pointed to by `p_addr_remote`.
    2. Return the actual size of socket address structure with the received data's remote address, if no error(s). Otherwise, return 0.

Returned Value

Number of positive data octets received, if no error(s).

0, if socket connection closed.

-1, otherwise.