This function receives sockets. (UDP compatible)

Syntax

int SyncRecvfromAddrSc(
  SOCKET sock,
  void *pvRecvBuf,
  unsigned short u16BufLen,
  unsigned long u32Timeoutmsec,
  unsigned short *u16RemainingLen,
  struct sockaddr_in *pstrRemoteAddr
);

Parameters

sock
[in] Socket descriptor
pvRecvBuf
[out] Specify the receive buffer.
u16BufLen
[in] Specify the size (bytes) of the receive buffer.
u32Timeoutmsec
[in] Specify the timeout (msec).
If you specify 0 or 4294967295 (0xFFFFFFFF), it will not time out.
u16RemainingLen
[out] The remaining size (in bytes) of the current receive operation.
pstrRemoteAddr
[out]A pointer to the sockaddr_in structure.

Return value

The following values will be returned.
ValueDescription
Positive number Receive size.
SOCK_ERR_TIMEOUT If no data was received during the timeout.
SOCK_ERROR Socket error
Close the socket and recreate it.
SOCK_CLOSE Remote disconnect
Close the socket and recreate it.
SOCK_RECV_ERROR Receive error
The receive size has exceeded the buffer size.
Please adjust the buffer size to an appropriate size.
M2M_ERR_SLEEP_FAIL Initialize with SysWLANInit function.
Other than the above Failed

Remarks

Since TH15J09, the API name has been changed from SyncRecvfromSc to SyncRecvfromAddrSc, and pstrRemoteAddr has been added as the 6th argument.
Specify NULL if you do not use pstrRemoteAddr
SyncRecvfromSc can be used as before, but we recommend migrating to SyncRecvfromAddrSc.

Requirements

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

Last updated: 2020/10/14