Receive using TCP socket.

Syntax

short RecvSc(
  SOCKET sock, 
  void *pvRecvBuf, 
  unsigned short u16BufLen,
  unsigned long u32Timeoutmsec
);

Parameters

sock
[in] socket descriptor
pvRecvBuf
[out] Specify the receive buffer.
u16BufLen
Specify the receive buffer size.
u32Timeoutmsec
[in] Specify the timeout (msec). If you specify 0 or 4294967295 (0xFFFFFFFF), it will not time out.

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

Receive using TCP socket.
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_RECV
pvMsg
A pointer to the tstrSocketRecvMsg structure that stores the processing result.


tstrSocketRecvMsg structure (typedef)

Syntax

typedef struct
{
    unsigned char       *pu8Buffer;
    short               s16BufferSize;
    unsigned short      u16RemainingSize;
    struct sockaddr_in  strRemoteAddr;
} tstrSocketRecvMsg;

Members

pu8Buffer
Buffer specified by RecvfromSc function. (This may be NULL when the function fails, .)
s16BufferSize
Received data size or error:
ValueDescription
Received data size Succeeded
Larger than the buffer size Failed
Less than or equal to 0 Failed
u16RemainingSize
Remaining size of received data.
strRemoteAddr
Not used in the RecvSc function.


Requirements

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

Sample

Last updated: 2020/11/26