FB_TlsSocketCreate

The function block FB_TlsSocketCreate can be used to create a new socket via the TwinCAT TCP/IP Connection Server, either for a server (bListener:=true) or client application (bListener:=false). 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 (hSocket) is returned at the hListner output. This handle is required by the function block FB_TlsSocketListen, and subsequently FB_SocketAccept. If a listener socket is no longer required, it can be closed with the function block FB_SocketClose. After the execution of the function block FB_TlsSocketCreate TLS parameters can be set to secure the communication connection. This is done using the function blocks FB_TlsSocketAddCa, FB_TlsSocketAddCrl, FB_TlsSocketSetCert and FB_TlsSocketSetPsk. Programming samples for this can be found in our samples.
Inputs
VAR_INPUT
sSrvNetId : T_AmsNetId:='';
bListener : BOOL:=FALSE;
bExecute : BOOL;
tTimeout : TIME:=T#5s;
END_VAR
Name | Type | Description |
---|---|---|
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. |
bListener | BOOL | Creates a new socket handle. |
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. |
Outputs
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
hSocket : T_HSOCKET;
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. |
hSocket | T_HSOCKET | Connection handle for the new socket. |
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) |