Assign a socket address to the socket.

Syntax

char BindSc(
  SOCKET sock,
  struct sockaddr *pstrAddr,
  unsigned char u8AddrLen
);

Parameters

sock
[in] Socket descriptor
pstrAddr
[in] Specify the socket address to be assigned to the socket with sockaddr structure.
In this library, define a sockaddr_in structure and use it for sockaddr structure with cast.
u8AddrLen
[in]Specify the size of the sockaddr structure.
In this library, specify the size of sockaddr_in structure.

Return value

The following values will be returned.
ValueDescription
SOCK_ERR_NO_ERROR Succeeded
M2M_ERR_SLEEP_FAIL Initialize with SysWLANInit function.
Other than the above Failed

Remarks

Assign a socket address to the socket.
It can be used with both TCP and UDP sockets.

The processing request of this function is processed asynchronously. The processing result is received by the callback function specified by the pfAppSocketCb parameter of the RegSocketCallbackSc function. The following values are passed to the parameters of the callback function.
sock
Socket descriptor
u8Msg
SOCKET_MSG_BIND
pvMsg
A pointer to the tstrSocketBindMsg structure that stores the processing result.


tstrSocketBindMsg structure (typedef)

Syntax

typedef struct{
  sint8  status;
}tstrSocketBindMsg;

Members

status
Returns 0 if the BindSc process is successful, otherwise it returns a negative value.


Requirements

Header file:
lib.h
Library file:
libSTARTUPOPH5000.a

Sample

Last updated: 2020/11/26