Syntax
char ConnectSc(
SOCKET sock,
struct sockaddr *pstrAddr,
unsigned char u8AddrLen
);
Parameters
- sock
-
[in] Socket descriptor
- pstrAddr
-
[in] Specify the socket address to connect to the socket with the 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.。Value | Description |
---|---|
SOCK_ERR_NO_ERROR | Succeeded |
M2M_ERR_SLEEP_FAIL | Initialize with SysWLANInit function. |
Other than the above | Failed |
Remarks
This function makes a connection with the server.Only available on TCP 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_CONNECT
- pvMsg
- A pointer to the tstrSocketConnectMsg structure that stores the processing result.
tstrSocketConnectMsg structure (typedef)
Syntax
typedef struct {
SOCKET sock;
signed char s8Error;
} tstrSocketConnectMsg;
Members
- sock
- Socket specified in ConnectSc argument
- s8Error
- Returns 0 if the ConnectSc process is successful, otherwise it returns a negative value.
Requirements
Header file:
lib.hLibrary file:
libSTARTUPOPH5000.a
Sample
Last updated: 2020/11/26