TcpSend
Function Block - Sends characters over a socket.
- It is possible the number of characters actually sent is less than the number expected.
- In this case, use this function again to send the pending characters.
-
- 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.
Inputs
|
Input |
Data Type See Data Types. |
Range |
Unit |
Default |
Description |
|---|---|---|---|---|---|
|
Execute |
BOOL |
0 to 1 |
N/A |
No default |
On the rising edge, send a string over a socket connection. |
|
ID |
UDINT |
N/A |
N/A |
No default |
The ID of the client socket. |
|
NbChar |
DINT |
N/A |
N/A |
No default |
The number of characters to send. |
|
Data |
STRING |
N/A |
N/A |
No default |
The IP Address of the remote server. |
Outputs
|
Output |
Data Type See Data Types. |
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, Recipe, and TCP/IP Function Block ErrorIDs. |
|
NbSent |
DINT |
|
|
The number of characters actually sent. |
FBD Language Example
Not available.
FFLD Language Example
Not available.
IL Language Example
Not available.
ST Language Example
(* TcpSend example *)
CASE StepCounter OF
0:
Inst_TcpSend(TRUE, MySocketID, 5, 'Hello');
StepCounter := StepCounter + 1;
1:
Inst_TcpSend(TRUE, MySocketID, 5, 'Hello');
IF Inst_TcpSend.Done THEN
BytesSent := Inst_TcpSend.NbSent;
Inst_TcpSend(FALSE, 0, 0, '');
StepCounter := StepCounter + 1;
END_IF;
END_CASE;
See Also





