NetApp_SockBind TCP-UDP

Bind an application socket to a local address, with error handling. See section NetSock_Bind() for more information.

Files

net_app.h/net_app.c

Prototype

          CPU_BOOLEAN  NetApp_SockBind (NET_SOCK_ID         sock_id,
                                        NET_SOCK_ADDR      *p_addr_local,
                                        NET_SOCK_ADDR_LEN   addr_len,
                                        CPU_INT16U          retry_max,
                                        CPU_INT32U          time_dly_ms,
                                        NET_ERR            *p_err);

Arguments

sock_id

This is the socket ID returned by NetApp_SockOpen()/ NetSock_Open()/socket() when the socket was created.

p_addr_local

Pointer to a socket address structure (see section Network Sockets Concepts) which contains the local host address to bind the socket to.

addr_len

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

retry_max

Maximum number of consecutive socket bind retries.

time_dly_ms

Socket bind 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_NONE_AVAIL
NET_APP_ERR_INVALID_ARG
NET_APP_ERR_INVALID_OP
NET_APP_ERR_FAULT

Returned Value

DEF_OK,

Application socket successfully bound to a local address.

DEF_FAIL,

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) then 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.