FB_TlsSocketListen

FB_TlsSocketListen 1:

The function block FB_TLsSocketListen can be used to open a new listener socket secured via TLS 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. The socket handle created with the function block FB_TlsSocketCreate can then be used by the function block FB_SocketAccept to accept an incoming client request. 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. Programming samples for using this function block can be found in our samples.

FB_TlsSocketListen 2: Inputs

VAR_INPUT
    sSrvNetId  : T_AmsNetId:='';
    sLocalHost : T_IPv4Addr:='';
    nLocalPort : UDINT:=0;
    flags      : ST_TlsListenFlags:=DEFAULT_TLSLISTENFLAGS;
    bExecute   : BOOL;
    tTimeout   : TIME:=T#5s;
END_VAR

Name

Type

Description

hListener

T_HSOCKET

Socket handle, which was created via the function block FB_TlsSocketCreate.

sSrvNetId

T_AmsNetId

String containing the network address of the TwinCAT TCP/IP Connection Server. For the local computer (default) an empty string may be specified.

sLocalHost

T_IPv4Addr

Local server IP address (Ipv4) in the form of a string (e.g. 172.13.15.2). For a server on the local computer (default), an empty string may be entered.

nLocalPort

UDINT

Local server IP port (e.g. 200).

flags

ST_TlsListenFlags

Additional (optional) server connection settings.

bExecute

BOOL

The function block is enabled by a positive edge at this input.

tTimeout

TIME 

Maximum time allowed for the execution of the function block.

FB_TlsSocketListen 3: Inputs/outputs

VAR_IN_OUT
    hListener : T_HSOCKET;
END_VAR

Name

Type

Description

hListener

T_HSOCKET

Connection handle to the new listener socket.

FB_TlsSocketListen 4: Outputs

VAR_OUTPUT
    bBusy  : BOOL;
    bError : BOOL;
    nErrId : UDINT;
END_VAR

Name

Type

Description

bBusy

BOOL

This output is active if the function block is activated. It remains active until acknowledgement.

bError

BOOL

If an error should occur during the transfer of the command, then this output is set once the bBusy output was reset.

nErrId

UDINT

If an bError output is set, this parameter returns the TwinCAT TCP/IP Connection Server error number.

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TF6310 v3.3.15.0 or later

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_TcpIp (Communication)