Function BlockTcpBinSendPLCopen motion icon

Description

This function block sends characters over a socket. It is possible that the number of characters actually sent is less than the number expected. In that case, you will need to use TcpBinSend 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. You must use the TcpIsValid function block after TcpSend. If the socket is no longer valid then you must close it by using the TcpClose function block.

Figure 7-219: The TcpBinSendf function block

Related Functions

TcpAccept, TcpBinReceive, TcpClose, TcpConnect, TcpIsConnected, TcpIsValid, TcpListen, TcpReceive, TcpSend

Arguments

Input

Execute Description On the rising edgeClosed A rising edge is the transition of a digital signal from low to high. It is also called positive edge send a string over a socket connection.
  Data Type BOOL
  Range 0, 1
  Unit N/A
  Default
ID Description The ID of the client socket
  Data Type UDINT
  Range N/A
  Unit N/A
  Default
Data Description The data array to send
  Data Type USINT[]
  Range N/A
  Unit N/A
  Default
DataSize Description Number of bytes in the Data array to send.
  Data Type DINT
  Range N/A
  Unit N/A
  Default

Output

Done Description If TRUE, then the command completed successfully
  Data Type BOOL
Error Description If TRUE, an error has occurred
  Data Type BOOL
ErrorID Description Indicates the error if Error output is set to TRUE. See the table in Search IndexFile and TCP/IP Function Block ErrorID Output
  Data Type DINT
NbSent Description The number of characters actually sent.
  Data Type DINT

Example

Structured Text

(* TcpBinSend example *)
CASE StepCounter OF
0:
  Inst_TcpBinSend(TRUE, MySocketID, MyDataArray, 256);
  StepCounter := StepCounter + 1;
1:
  Inst_TcpBinSend(TRUE, MySocketID, MyDataArray, 256);
  IF Inst_TcpBinSend.Done THEN
     BytesSent := Inst_TcpBinSend.NbSent;
     Inst_TcpBinSend(FALSE, 0, MyDataArray, 0);
     StepCounter := StepCounter + 1;
  END_IF;
END_CASE;