FB_SocketListen
Using the function block FB_SocketListen, a new listener socket can be opened via the TwinCAT TCP/IP Connection Server. Via a listener socket, the TwinCAT TCP/IP Connection Server can 'listen' for incoming connection requests from remote clients. If successful, the associated connection handle is returned at the hListner output. This handle is required by the function block FB_SocketAccept . If a listener socket is no longer required, it can be closed with the function block FB_SocketClose. The listener sockets on an individual computer must have unique IP port numbers.
VAR_INPUT
VAR_INPUT
sSrvNetId : T_AmsNetId := '';
sLocalHost : STRING(15);
nLocalPort : UDINT;
bExecute : BOOL;
tTimeout : TIME := T#5s;
END_VAR
sSrvNetId: String containing the network address of the TwinCAT TCP/IP Connection Server. For the local computer (default) an empty string may be specified.
sLocalHost: Local server IP address (Ipv4) as a string (e.g. '172.13.15.2'). For a server on the local computer (default), an empty string may be entered.
nLocalPort: Local server IP port (e.g. 200).
bExecute: The block is activated by a rising edge at this input.
tTimeout: Maximum time allowed for the execution of the function block.
VAR_OUTPUT
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
hListener : T_HSOCKET;
END_VAR
bBusy: When the function block is activated this output is set. It remains set until and acknowledgement is received.
bError: If an error should occur during the transfer of the command, then this output is set once the bBusy output was reset.
nErrId : If the bError output is set, this parameter returns the TwinCAT TCP/IP Connection Server error number.
hListener: Connection handle for the new listener socket.
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) |