TCP_RECEIVE DFB
(Original Document)
Overview
The TCP_RECEIVE DFB allows a data message to be received from a remote client application via a TCP/IP connection. The maximum size of the message is 8 kb.
Input Parameters
Parameter
Type
Description
RST
bit
Setting this bit to 1:
  • interrupts the exchange in progress (if the ACTIVITY bit is set to 1)
  • closes the connection
  • sets the ACTIVITY bit to 0 and the ERROR output bit to 1
The error code is found in the STATUS word.
Input/Output Parameters
Parameter
Type
Description
BUF
word table
This input and output parameter defines the address of the first %MWi word of the buffer in order to receive the message.
MANAGNT
word table
Management table common to all DFBs
Output Parameters
Parameter
Type
Description
ERROR
bit
This output bit is set to 1 if the exchange is not carried out correctly.
The STATUS word indicates the type of error that has occurred.
Internal Public Data
Parameter
Type
Write/Read Variables
Description
FRM
double word
W
This variable defines the IP address of the remote machine on which the client is connected.
By default, FRM = 0, and the DFB awaits the message sent by the unique remote client connected to the local service port of the PLC.
PORT
word
W
This variable defines the number of the local port to which the remote client is connected.
SIZE
word
W
This variable defines the size of the message to be sent, from 0 to 8192 bytes.
ACTIVITY
bit
R
This variable is set to 0 by the DFB when the exchange is finished. If the ERROR output bit is set to 0, the ACTIVITY bit indicates that the message has been received successfully. However, if the ERROR bit is set to 1, the ACTIVITY bit indicates that the exchange finished, but has errors.
INHIB
bit
W
This variable allows the error warning to be inhibited. The ERROR output bit and the STATUS word remain at 0 (execution of the block is not interrupted).
STATUS
word
R
This word is only significant if the ERROR output bit is set to 1. It indicates the error code that occurred during the exchange (each word bit set to 1 indicates an error).
LENGTH
word
R
This variable contains the number of bytes received if the ERROR output bit is set to 0.
Operation
Data transfer is triggered when the TCP_RECEIVE DFB is called, if the RST and ACTIVITY bits are set to 0. During the exchange, the ACTIVITY bit is set to 1. At the end of transmission, the ACTIVITY bit is set to 0. In addition, if the exchange is not correct, the ERROR output bit is set to 1.
At any time, setting the RST bit (priority input) to 1 allows the exchange in progress to be interrupted. The ACTIVITY bit (exchange finished) is set to 0, and the ERROR bit is set to 1. The status word <TCP_RECEIVE instance name>.STATUS indicates the type of error. If the connection is open, it closes, and the module waits for the incoming connection. Any messages in the module’s receive buffers are lost.
When a message is received, the following process occurs:
As soon as a DFB is active for a given connection, the module awaits the message to be received, and the first two bytes received indicate the length of the message. The data is then transferred into the PLC’s words in frames of 240 bytes.
When the full message is copied onto the PLC: