TcpIsConnected
Function Block A function block groups an algorithm and a set of private data. It has inputs and outputs. - Tests if a client socket is connected.
Inputs
Input |
Data Type |
Range |
Unit |
Default |
Description |
---|---|---|---|---|---|
Execute |
BOOL |
0, 1 |
N/A |
No default |
On the rising edge A rising edge is the transition of a digital signal from low to high. It is also called positive edge, test whether a socket is connected. |
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 Search IndexFile and TCP/IP Function Block ErrorIDs. |
Connected |
BOOL |
|
|
TRUE if a connection is correctly established. |
Remarks
-
- It is possible that the socket becomes invalid if an error occurs in the TCP connection after this function block is called.
Use the TcpIsValid function block after TcpSend.
If the socket is no longer valid, close it using the TcpClose function block.
Figure 6-281: TcpIsConnected
FBD Language Example
Not available.
FFLD Language Example
Not available.
IL Language Example
Not available.
ST Language Example
(* TcpIsConnected example *)
CASE StepCounter OF
0:
Inst_TcpIsConnected(TRUE, MySocketID);
StepCounter := StepCounter + 1;
1:
Inst_TcpIsConnected(TRUE, MySocketID);
IF Inst_TcpIsConnected.Done THEN
MyTcpIsConnected := Inst_TcpIsConnected.Connected;
Inst_TcpIsConnected(FALSE, 0);
StepCounter := StepCounter + 1;
END_IF;
END_CASE;
See Also