Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Unable to render {include} The included page could not be found.
Unable to render {include} The included page could not be found.

NetApp_SockRx() (TCP/UDP)

Receive application data via socket, with error handling. See section C-13-46 on page 659 for more information.

Files

net_app.h/net_app.c

Prototype

CPU_INT16U NetApp_SockRx (NET_SOCK_ID sock_id,

void *pdata_buf,

CPU_INT16U data_buf_len,

CPU_INT16U data_rx_th,

CPU_INT16S flags,

NET_SOCK_ADDR *paddr_remote,

NET_SOCK_ADDR_LEN *paddr_len,

CPU_INT16U retry_max,

CPU_INT32U timeout_ms,

CPU_INT32U time_dly_ms,

NET_ERR *perr);

Arguments

sock_id

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

pdata_buf

Pointer to the application memory buffer to receive data.

data_buf_len

Size of the destination application memory buffer (in bytes).

data_rx_th

Application data receive threshold:

0, no minimum receive threshold; i.e. receive any amount of data. Recommended for datagram sockets;

Minimum amount of application data to receive (in bytes) within maximum number of retries, otherwise.

flags

Flag to select receive options; bit-field flags logically OR’d:

NET_SOCK_FLAG_NONE/0
No socket flags selected
NET_SOCK_FLAG_RX_DATA_PEEK/
 
MSG_PEEK
Receive socket data without consuming it
NET_SOCK_FLAG_RX_NO_BLOCK/
 
MSG_DONTWAIT
Receive socket data without blocking
 

In most cases, this flag would be set to NET_SOCK_FLAG_NONE/0.

paddr_remote

Pointer to a socket address structure (see section 8-2 “Socket Interface” on page 212) to return the remote host address that sent the received data.

paddr_len

Pointer to the size of the socket address structure which must be passed the size of the socket address structure [e.g., sizeof(NET_SOCK_ADDR_IP)]. Returns size of the accepted connection’s socket address structure, if no errors; returns 0, otherwise.

retry_max

Maximum number of consecutive socket receive retries.

timeout_ms

Socket receive timeout value per attempt/retry.

time_dly_ms

Socket receive delay value, in milliseconds.

perr

Pointer to variable that will receive the error code from this function:

NET_APP_ERR_NONE

 

NET_APP_ERR_INVALID_ARG

 

NET_APP_ERR_INVALID_OP

 

NET_APP_ERR_FAULT

 

NET_APP_ERR_FAULT_TRANSITORY

 

NET_APP_ERR_CONN_CLOSED

 

NET_APP_ERR_DATA_BUF_OVF

 

NET_ERR_RX

 

Returned Value

Number of data bytes received, if no errors.

0, otherwise.

Required Configuration

Available only if NET_APP_CFG_API_EN is enabled (see section D-18-1 on page 768) and either NET_CFG_TRANSPORT_LAYER_SEL is configured for TCP (see section D-12-1 on page 755) and/or NET_UDP_CFG_APP_API_SEL is configured for sockets (see section D-13-1 on page 756).

Notes / Warnings

Some socket arguments and/or operations are validated only if validation code is enabled (see section D-3-1 on page 744).

If a non-zero number of retries is requested (retry_max) and socket blocking is configured for non-blocking operation (see section D-15-3 on page 761); then a non-zero timeout (timeout_ms) and/or a non-zero time delay (time_dly_ms) should also be requested. Otherwise, all retries will most likely fail immediately since no time will elapse to wait for and allow socket operations to successfully complete.

  • No labels