SysSockRecvMsg (FUN)

FUNCTION SysSockRecvMsg : __XINT

Receives a message from a socket.

NOTE: For querying the SOCKET_MSG_BCAST message flag the IP_PKTINFO socket option has to be set on the socket.

NOTE: With some IP stacks (LwIP for example, which is used with the CODESYS Control RTE), it is necessary to set the SOCKET_SO_BROADCAST socket option (SOCKET_SOL level) in order to be able to receive broadcast UDP messages with the SysSockRecvMsg() and SysSockRecvFrom() functions.

NOTE: If no messages are available at the socket and SOCKET_FIONBIO is not set on the socket, SysSockRecvMsg() shall block until a message arrives.

InOut:

Scope

Name

Type

Comment

Return

SysSockRecvMsg

__XINT

Upon successful completion, SysSockRecvMsg() shall return the length of the message in bytes. If no messages are available to be received and the peer has performed an orderly shutdown, SysSockRecvMsg() shall return 0 and set *pResult to ERR_SOCK_CLOSED. Otherwise, the function shall return 0 and set *pResult to indicate the error.

Input

hSocket

RTS_IEC_HANDLE

Handle to the socket.

pMessage

POINTER TO SOCK_RECVMSG_MSG

Points to a SOCK_RECVMSG_MSG structure, containing both the buffer to store the source address and the buffer for the incoming message. The length and format of the address depend on the address family of the socket. The msgFlags and msgFlagsSupported members are ignored on input, but may contain meaningful values on output.

flags

DWORD

Specifies the type of message reception. Values of this argument are formed by logically OR’ing zero or more of the SOCKET_MSG values. See category “Message flags”.

pResult

POINTER TO RTS_IEC_RESULT

Pointer to runtime system error code (see CmpErrors.library)