T_HSOCKET

Variables of this type represent a connection handle or a handle of an open socket. Via this handle, data can be sent to or received from a socket. The handle can be used to close an open socket.

TYPE T_HSOCKET
STRUCT
    handle          : UDINT;
    localAddr       : ST_SockAddr; (* Local address *)
    remoteAddr      : ST_SockAddr; (* Remote endpoint address *)
END_STRUCT
END_TYPE

handle: Internal TwinCAT TCP/IP Connection Server socket handle;

localAddr: Local socket address;

remoteAddr: Remote socket address;

The following sockets can be opened and closed via the TwinCAT TCP/IP Connection Server: listener socket, remote client socket, or local client socket. Depending on which of these sockets was opened by the TwinCAT TCP/IP Connection Server, suitable address information is entered into the localAddr and remoteAddr variables.

Connection handle on the server side

Connection handle on the client side

The function block FB_SocketCloseAll can be used to close all connection handles (sockets) that were opened by a PLC runtime system. This means that, if FB_SocketCloseAll is called in one of the tasks of the first runtime systems (port 801), all sockets that were opened in the first runtime system are closed.

Requirements

Development environment

Target system type

PLC libraries to be linked

TwinCAT version 2.8.0 or higher

PC or CX (x86)

TcpIp.Lib

( Standard.Lib; TcBase.Lib; TcSystem.Lib are included automatically )

TwinCAT v2.10.0 Build >= 1301

CX (ARM)