SysSock2Htons (FUN) ¶ FUNCTION SysSock2Htons : WORD Converts a value of type short from order of the TCP/IP network to the host byte order. InOut: Scope Name Type Comment Return SysSock2Htons WORD Converted WORD value Input usHost WORD Ethernet value
SysSock2InetAddr (FUN) ¶ FUNCTION SysSock2InetAddr : RTS_IEC_RESULT Convert an IP address string into an IP address. InOut: Scope Name Type Comment Return SysSock2InetAddr RTS_IEC_RESULT Runtime system error code (see CmpErrors.library). Input szIPAddress REFERENCE TO STRING Pointer to get IP address string (must be at least 16 bytes long) pInAddr POINTER TO UDINT Pointer to IP address description
SysSock2InetNtoa (FUN) ¶ FUNCTION SysSock2InetNtoa : RTS_IEC_RESULT Convert IP address to a string. InOut: Scope Name Type Comment Return SysSock2InetNtoa RTS_IEC_RESULT Runtime system error code (see CmpErrors.library). Input pInAddr POINTER TO INADDR Pointer to IP address description szIPADDR REFERENCE TO STRING Pointer to get IP address string (must be at least 16 bytes long) diIPAddrSize DINT Maximum length of szIPAddr
SysSock2Ioctl (FUN) ¶ FUNCTION SysSock2Ioctl : RTS_IEC_RESULT Io-control of a socket. InOut: Scope Name Type Comment Return SysSock2Ioctl RTS_IEC_RESULT Runtime system error code (see CmpErrors.library). Input hSocket RTS_IEC_HANDLE Handle to the socket diCommand DINT Io-control command pdiParameter POINTER TO DINT Parameter value of the command
SysSock2Listen (FUN) ¶ FUNCTION SysSock2Listen : RTS_IEC_RESULT Listen on a TCP server socket for new connection. InOut: Scope Name Type Comment Return SysSock2Listen RTS_IEC_RESULT Runtime system error code (see CmpErrors.library). Input hSocket RTS_IEC_HANDLE Handle to the socket diMaxConnections DINT Maximum number of connections allowed
SysSock2Ntohl (FUN) ¶ FUNCTION SysSock2Ntohl : UDINT Convert a UDINT value from ethernet byte order into host format. InOut: Scope Name Type Comment Return SysSock2Ntohl UDINT Converted UDINT value Input ulNet UDINT Ethernet value
SysSock2Ntohs (FUN) ¶ FUNCTION SysSock2Ntohs : WORD Convert a WORD value from ethernet byte order into host format. InOut: Scope Name Type Comment Return SysSock2Ntohs WORD Converted WORD value Input usNet WORD Ethernet value
SysSock2Recv (FUN) ¶ FUNCTION SysSock2Recv : __XINT Receive data from a TCP socket. InOut: Scope Name Type Comment Return SysSock2Recv __XINT Number of bytes received. 0 if failed. Input hSocket RTS_IEC_HANDLE Handle to the socket pbyBuffer POINTER TO BYTE Buffer to read data from the socket diBufferSize __XINT Maximum length of the buffer diFlags DINT The flags parameter can be used to influence the behavior of the function beyond the options specified for the associated socket. The semantics of this function are determined by the socket options and the flags parameter. The latter is constructed by using the bitwise OR operator with any of the SOCKET_MSG values. See category “Message flags”. pResult POINTER TO RTS_IEC_RESULT Pointer to runtime system error code (see CmpErrors.library)
SysSock2RecvFrom (FUN) ¶ FUNCTION SysSock2RecvFrom : __XINT Receive a message from a connectionless socket (UDP). 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 SysSock2RecvMsg() and SysSock2RecvFrom() functions. InOut: Scope Name Type Comment Return SysSock2RecvFrom __XINT Number of bytes received Input hSocket RTS_IEC_HANDLE Handle to the socket pbyBuffer POINTER TO BYTE Buffer to read data from the socket diBufferSize __XINT Maximum length of the buffer diFlags DINT The flags parameter can be used to influence the behavior of the function beyond the options specified for the associated socket. The semantics of this function are determined by the socket options and the flags parameter. The latter is constructed by using the bitwise OR operator with any of the SOCKET_MSG values. pSockAddr POINTER TO SOCKADDRESS Socket address and port to receive data from diSockAddrSize DINT Size of socket address structure pResult POINTER TO RTS_IEC_RESULT Pointer to runtime system error code (see CmpErrors.library)
SysSock2RecvMsg (FUN) ¶ FUNCTION SysSock2RecvMsg : __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 SysSock2RecvMsg() and SysSock2RecvFrom() functions. NOTE: If no messages are available at the socket and SOCKET_FIONBIO is not set on the socket, SysSock2RecvMsg() shall block until a message arrives. InOut: Scope Name Type Comment Return SysSock2RecvMsg __XINT Upon successful completion, SysSock2RecvMsg() 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, SysSock2RecvMsg() 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)