FB_IpClose

The function block is required for closing a TCP/IP connection from the PLC controller. With a positive edge of bStart a connection with the IP address from sRemoteIpAddr is terminated. The function block sends a FIN signal and waits for the confirmation of the disconnection. The partner device and the connection must exist and be operational. If bResetConnection is set the function block sends a signal to indicate that the connection was terminated, but it does not wait for confirmation from the other device. bBusy is set as long set as the function block is active. If bBusy is reset and bError is FALSE the TCP/IP connection was terminated successfully.

FB_IpClose 1:
Function block FB_IPCLOSE

INPUT

VAR_INPUT
   bStart           : BOOL;
   iSession         : WORD;
   sRemoteIPAddr    : STRING(15);
   iPortNo          : WORD;
   bResetConnection : BOOL;
END_VAR

bStart: A rising edge activates the function block.

iSession: Is linked with the session number from function block FB_IpStartSession.

sRemoteIPAddr: IP address of the device with which the connection is to be terminated.

iPortNo: Port number of the device with which the connection is to be terminated.

bResetConnection: FALSE: FIN is sent; TRUE: the TCP/IP connection is closed without waiting for acknowledgement from the partner device. In both cases a new Open is required for re-establishing the connection.

OUTPUT

VAR_OUTPUT
   bBusy        : BOOL;
   bError       : BOOL;
   iErrorId     : WORD;
END_VAR

bBusy: This output remains TRUE until execution of the command is complete.

bError: This output is switched to TRUE as soon as an error occurs during the execution of a command. The command-specific error code is contained in iErrorId.

iErrorId: Contains the command-specific error code of the most recently executed command (see table).