Syntax
char AcceptSc(
SOCKET sock,
struct sockaddr *addr,
unsigned char *addrlen
);
Parameters
- sock
-
[in] Socket descriptor
- addr
-
[in] Set NULL.
- addrlen
-
[in] Set 0.
Return value
Returns SOCK_ERR_NO_ERROR if the function succeeds, other values otherwise.Remarks
This function waits for a socket connection.This function can only be used with TCP sockets.
It is not necessary to call this API, but it is necessary to process the callback message.
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_ACCEPT
- pvMsg
- A pointer to a tstrSocketAcceptMsg structure that stores the information of the accepted remote socket.
Note:
- When ListenSc function is executed, the SOCKET_MSG_ACCEPT message is generated when there is a connection request from a client without calling this API.
tstrSocketAcceptMsg structure (typedef)
Syntax
typedef struct {
SOCKET sock;
struct sockaddr_in strAddr;
} tstrSocketAcceptMsg;
Member
- sock
- Accepted remote socket.
- strAddr
- Socket address of the accepted remote socket is returned by sockaddr_in structure.
Requirements
Header file:
lib.hLibrary file:
libSTARTUPOPH5000.a
Last updated: 2020/11/26