FB_SocketClose

FB_SocketClose 1:

The function block FB_SocketClose can be used to close an open TCP/IP or UDP socket.

TCP/IP: The listener socket is opened with the function block FB_SocketListen, a local client socket with FB_SocketConnect and a remote client socket with FB_SocketAccept.

UDP: The UDP socket is opened with the function block: FB_SocketUdpCreate.

VAR_INPUT

VAR_INPUT
    sSrvNetId       : T_AmsNetId := '';
    hSocket         : T_HSOCKET; 
    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.

hSocket: TCP/IP: Connection handle of the listener, remote or local client socket to be closed. UDP: Connection handle of the UDP socket.

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;
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.

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)