TcpClose

PLCopen motion icon

 Function Block - Closes and releases a socket.

Inputs

Input

Data Type

Range

Unit

Default

Description

Execute

BOOL

0, 1

N/A

No default

On the rising edge, close a socket.

ID

UDINT

N/A

N/A

No default

The ID of the client socket.

Outputs

Output

Data Type

Range

Unit

Description

Done

BOOL

 

 

If TRUE, the command completed successfully.

Error

BOOL

 

 

If TRUE, an error has occurred.

ErrorID

DINT

 

 

Indicates the error if Error output is TRUE.

See the table in File and TCP/IP Function Block ErrorIDs.

Remarks

You are responsible for closing any socket created by the TcpListen, TcpAccept, or TcpConnect function blocks, even if they have become invalid.

Figure 1: TcpClose

FBD Language Example

Not available.

FFLD Language Example

Not available.

IL Language Example

Not available.

ST Language Example

(* TcpClose example *)
CASE StepCounter OF
0:
  Inst_TcpClose(TRUE, MySocketID);
  StepCounter := StepCounter + 1;
1:
  Inst_TcpClose(TRUE, MySocketID);
  IF Inst_TcpClose.Done THEN
     Inst_TcpClose(FALSE, 0);
     StepCounter := StepCounter + 1;
  END_IF;
END_CASE;

See Also