7.15.7 T_RESET
T_RESET (terminate and reconnect the specified connection)
Function
- T_RESET system library is used to asynchronously reset the current TCP connection
Set up and establish communication connections
-
After the user configures the correct IP address and port number in the connect block, by setting the REQ parameter to true, the reset connection function is enabled, the current communication connection is terminated and the connection request is re-created.
-
The reset connection function only works when the communication connection has been successfully established.
-
Correct reset process: you need to give the req pin a rising edge, you can see the status word in the T_RESET block from 0x7004 (connection has been established) → 0x7003 (is terminating the connection) → 0x7007 (has terminated the connection) → 0x7002 (is establishing a connection), the above state changes indicate that the connection has been reset successfully; to be re-triggered by the opposite end of the connection action. When the other end re-triggers the connection action, the status code of your side can be smoothly updated to 0x7004 (connection established successfully).
-
After the connection is established, if the opposite end takes the initiative to disconnect at this time, the status code will change from 0x7004 (established) to 0x7002 (connection is being established); if the connection is reset at this time, the reconnection operation will not be triggered
LD graphics

Parameter description
| Interface Variables | Declaration | Data Type | Description |
|---|---|---|---|
| REQ | Input | BOOL | Actively reset the connection only when rising edge is recognized |
| CONNECT | InOut | TCP_ConnectConfig | Example of function block to configure connection parameters, refer to TCP_Connectconfig |
| DONE | Output | BOOL | State parameter with the following possible values: 0: The reset connection has not been started or is still in progress 1: The reset connection has been successfully performed. This status will only show for one cycle |
| BUSY | Output | BOOL | State parameter with the following possible values: 0: Resetting the connection has not yet started or has been completed 1: Resetting the connection has not yet completed |
| ERROR | Output | BOOL | State parameter with the following possible values: 0: No error 1: Error resetting the connection |
| STATUS | Output | WORD | The status of the current function execution process |
Status code description
| STATUS(WORD 16#) | Description |
|---|---|
| 0000 | Uncalled |
| 7002 | Establishing communication connection |
| 7004 | Connection successfully established |
| 8000 | Resetting connection |
| The following are exception status codes | Description |
|---|---|
| 8080 | Failed to create socket, insufficient system socket resources |
| 8081 | Wrong IP address |
| 8082 | Reusable error in setting IP address and port number |
| 8083 | Bind address and port number with socket failure |
| 8084 | Failed to add server socket to EPoll listening queue |
| 8086 | Failed to receive new connection |
| 8087 | Failed to remove the Epoll Event corresponding to the client |
| 80A0 | Failed client-initiated connection to the server |
| 80A2 | Active disconnection failed |
| 80A3 | Failed to reset connection |
| 80AC | Asynchronous function enqueue failed |
Example
- LD example is shown in the following animation:

- ST example is shown in the following code:
T_RESET_1(
REQ:=RESET,
CONNECT:=TCP_CONNECTCONFIG_1,
DONE=>OUT,
BUSY=>OUT2,
ERROR=>OUT3,
STATUS=>OUT4
);