Chapter 6 Applied Instructions
6-515
API
Instruction code
Operand Function
2203 SCLOSE P
S
1
, S
2
Closing the socket
Device
X Y M S T C HC D L SM SR E PR K 16# “$” DF
Pulse instruction
16-bit instruction (5 Steps)
32-bit instruction
Symbol:
S
1
:
Socket mode Word
S
2
:
Socket number Word
Explanation:
1. S
1
is 1 if users want to close the TCP socket, and S
1
is 0 if users want to close the UDP socket.
S
2
is the socket number.
2. The operand S
1
should be either 0 or 1, and the operand S
2
should be within the range between
1 and 8.
3. Before closing the socket, users need to make sure that the socket has been connected.
Otherwise, the instruction is not executed.
4. If the TCP socket is closed by the server, the client continues to be connected to the local
communication port. If the TCP socket is closed is by the client, the client is not connected to the
local communication port. After the instruction is executed to close the TCP socket, the
corresponding flag is OFF.
5. After the instruction is executed to close the UDP socket, the corresponding flag is OFF.
6. If the TCP socket is closed, and no error occurs after the instruction is executed, the PLC is not
connected to the remote device, and the flag related to the connection’s being closed is ON. If
the connection is closed successfully, the flag related to the connection’s being closed is OFF. If
an error occurs, the error flag is ON.
Socket number
Being closing the
connection
Error flag
7. If the UDP socket is close, and no error occurs after the instruction is executed, the flag related
to the connection’s having been started is OFF. If an error occurs, the error flag is ON.