SysSock2Bind (FUN) ¶ FUNCTION SysSock2Bind : RTS_IEC_RESULT Bind a socket to a socket address and port number. This functions calls the function bind of the operating system, which will assign a local address to a socket that has already been allocated to an address by SysSock2Create , but not yet fixed uniquely. This is usually done previous to a call to functions like SysSock2Listen or SysSock2Accept . InOut: Scope Name Type Comment Return SysSock2Bind RTS_IEC_RESULT Runtime system error code (see CmpErrors.library). Input hSocket RTS_IEC_HANDLE Handle to the socket pSockAddr POINTER TO SOCKADDRESS Spcket address diSockAddrSize DINT Size of the socket address structure
SysSock2Accept (FUN) ¶ FUNCTION SysSock2Accept : RTS_IEC_HANDLE Accept the next incoming TCP connection. This functions calls the function accept of the operating system, which can accept a request to connect to a socket. A new descriptor (handle) for the socket is returned. The original socket is reset to the “listening” state (see SysSockListen). Note For TLS Sockets the blocking mode will be set to nonblocking for the new client sockets. If a blocking behavior is needed use SysSock2Ioctl to set the socket to blocking mode. This reflects the behavior of SysSock2Create for TLS sockets. InOut: Scope Name Type Comment Return SysSock2Accept RTS_IEC_HANDLE Handle to the new accepted socket or RTS_INVALID_HANDLE if failed. Input hSocket RTS_IEC_HANDLE Handle to the socket pSockAddr POINTER TO SOCKADDRESS Socket address of the client, who is connected pdiSockAddrSize POINTER TO DINT Pointer to size of socket address structure pResult POINTER TO RTS_IEC_RESULT Pointer to runtime system error code (see CmpErrors.library)
SysSock2Close (FUN) ¶ FUNCTION SysSock2Close : RTS_IEC_RESULT Close a socket. InOut: Scope Name Type Comment Return SysSock2Close RTS_IEC_RESULT Runtime system error code (see CmpErrors.library). Input hSocket RTS_IEC_HANDLE Handle to the socket
SysSock2Connect (FUN) ¶ FUNCTION SysSock2Connect : RTS_IEC_RESULT Connect as a client to a TCP server. InOut: Scope Name Type Comment Return SysSock2Connect RTS_IEC_RESULT Runtime system error code (see CmpErrors.library). Input hSocket RTS_IEC_HANDLE Handle to the socket pSockAddr POINTER TO SOCKADDRESS Socket address of the server to connect to diSockAddrSize DINT Size of socket address structure
SysSock2Create (FUN) ¶ FUNCTION SysSock2Create : RTS_IEC_HANDLE Create a new socket and return the socket handle. By now STD or TLS sockets are available. Using a STD socket results in the default socket behavior. Note Using the TLS socket results in an IPv4 TCP socket where the TLS protocol is used. Since additional handshaking has to be done, connection establishment takes some time longer. By default, these sockets are created as nonblocking . If a blocking behavior is needed this has to be set explicitly . Be aware that blocking TLS sockets can lead to deadlock situations if the peer does not send TLS data. This is a potential security risk, typically for server implementations. An attacker can create a connection and then stop sending TLS data, resulting in a denial of service attack. This situation is avoided with nonblocking sockets. To avoid this potential risk by default TLS based sockets are created as nonblocking by default. This applies to handles created by SysSock2Create and SysSock2Accept . If this has to be changed use the SysSock2Ioctl to setup the desired behavior. InOut: Scope Name Type Comment Return SysSock2Create RTS_IEC_HANDLE A handle to the created socket or INVALID_HANDLE if something went wrong. The return is a descriptor (handle) of the new socket, which is required as input parameter by other library functions like SysSock2Bind , SysSock2Connect etc. Input pParameter POINTER TO SysSocket2_Parameter Class specific parameters. See SysSock_Parameter for details pResult POINTER TO RTS_IEC_RESULT Pointer to runtime system error code (see CmpErrors.library)
SysSock2FdInit (FUN) ¶ FUNCTION SysSock2FdInit : RTS_IEC_RESULT Add a socket to a socket set. InOut: Scope Name Type Comment Return SysSock2FdInit RTS_IEC_RESULT Runtime system error code (see CmpErrors.library). Input hSocket RTS_IEC_HANDLE Socket to add pfs REFERENCE TO SOCKET_FD_SET Socket Set
SysSock2FdIsset (FUN) ¶ FUNCTION SysSock2FdIsset : BOOL Check if a socket is inside of a set. InOut: Scope Name Type Comment Return SysSock2FdIsset BOOL TRUE if it is inside the set, FALSE if not. Input hSocket RTS_IEC_HANDLE Socket to check pfs REFERENCE TO SOCKET_FD_SET Socket Set
SysSock2FdZero (FUN) ¶ FUNCTION SysSock2FdZero : RTS_IEC_RESULT Clear a Socket set. InOut: Scope Name Type Comment Return SysSock2FdZero RTS_IEC_RESULT Returns the runtime system error code (see CmpErrors.library). Input pfs REFERENCE TO SOCKET_FD_SET Socket Set
SysSock2GetOption (FUN) ¶ FUNCTION SysSock2GetOption : RTS_IEC_RESULT Set options of a specified socket. InOut: Scope Name Type Comment Return SysSock2GetOption RTS_IEC_RESULT Runtime system error code (see CmpErrors.library). Input hSocket RTS_IEC_HANDLE Handle to the socket diLevel DINT Level of the socket diOption DINT Socket option command pdiOptionValue POINTER TO BYTE Pointer to the option value pdiOptionLen POINTER TO DINT Lenght of option value
SysSock2GetPeerName (FUN) ¶ FUNCTION SysSock2GetPeerName : RTS_IEC_RESULT Returns the socket address of the peer to which a socket is connected. The SysSockGetPeerName function can be used only on a connected socket. InOut: Scope Name Type Comment Return SysSock2GetPeerName RTS_IEC_RESULT Runtime system error code (see CmpErrors.library). Input hSocket RTS_IEC_HANDLE Handle to the socket pSockAddr POINTER TO SOCKADDRESS Socket address of the peer pdiSockAddrSize POINTER TO DINT Pointer to size of socket address structure