NetApp_SockTx TCP-UDP

Transmit application data via socket, with error handling. See section NetSock_TxData() for more information.

Files

net_app.h/net_app.c

Prototype

          CPU_INT16U  NetApp_SockTx (NET_SOCK_ID         sock_id,
                                     void               *p_data,
                                     CPU_INT16U          data_len,
                                     CPU_INT16S          flags,
                                     NET_SOCK_ADDR      *p_addr_remote,
                                     NET_SOCK_ADDR_LEN   addr_len,
                                     CPU_INT16U          retry_max,
                                     CPU_INT32U          timeout_ms,
                                     CPU_INT32U          time_dly_ms,
                                     NET_ERR            *p_err);

Arguments

sock_id

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.

p_data

Pointer to the application data memory buffer to send.

data_len

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

flags

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

NET_SOCK_FLAG_NONE/0
NET_SOCK_FLAG_TX_NO_BLOCK/

No socket flags selected

MSG_DONTWAIT

Send socket data without blocking

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

p_addr_remote

Pointer to a socket address structure (see section Network Sockets Concepts) which contains the remote socket address to send data to.

addr_len

Size of the socket address structure which must be passed the size of the socket address structure [e.g., sizeof(NET_SOCK_ADDR_IPv4)].

retry_max

Maximum number of consecutive socket transmit retries.

timeout_ms

Socket transmit timeout value per attempt/retry.

time_dly_ms

Socket transmit delay value, in milliseconds.

p_err

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_ERR_TX

Returned Value

Number of data bytes transmitted, if no errors.

0, otherwise.

Required Configuration

None.

Notes / Warnings

Some socket arguments and/or operations are validated only if validation code is enabled (see section Argument Check Configuration).

If a non-zero number of retries is requested (retry_max) and socket blocking is configured for non-blocking operation; 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.