TCP Receive
R2026bLibraries:
STM32 Microcontroller Blockset /
(Legacy) STM32 MBED Based Boards /
STM32F7
STM32 Microcontroller Blockset /
(Legacy) STM32 MBED Based Boards /
STM32H7
Description
The TCP Receive block receives data from a remote host or other target
hardware over a network. When you set Connection mode to
Server, you must provide the Local IP Port.
The Local IP Port acts as the listening port of the TCP/IP server.
When you set Connection mode to Client, you must
provide the Server IP Address and the Server IP
Port on the server from which to receive the data. The server must be up
and running before deploying the model that contains the TCP Receive
block to the target.
The block accepts data either in blocking mode or in non-blocking mode. In blocking mode, the model blocks the execution while it waits for the requested data to be available. In non-blocking mode, the model runs continuously. To set the block in blocking mode, select the Wait until data received option.
Note
Ensure to configure the Ethernet options in STM32CubeMX project. For more, see Ethernet Configuration in STM32CubeMX for STM32 Processor-Based Boards.
In the blocking mode, the model blocks the execution while it waits for the requested data to become available.

At time step 1, the block requests four data, and the buffer gets four data values. The block returns the four received data values at the Data port, and the execution continues.
At time step 2, the block requests data again, but the buffer gets only three values.
Because the requested data size is 4, the block waits until the buffer
receives the fourth data value or the timeout value elapses. During this phase, the
execution pauses.
At time step 3, the buffer contains sufficient data to satisfy the request. The block returns the first four data values in the order received, and the execution resumes. Any remaining data values are used in the next receipt cycle.
In non-blocking mode, the model runs continuously.

At time step 1, the block requests data, and the buffer gets four data values. The block
sets the Status port value to 1, indicating that the
requested data is available. The Data port, at this point, contains the newly
received data values.
At time step 2, the block requests data again, but the buffer gets only three values. The
block cannot return the data because the data size is specified as 4.
Therefore, the block sets the Status port value to 0,
indicating that the requested data is not available. All values on the Data
port become 0. The buffer, at this point, has three data values.
However, during this phase, the execution does not stop unlike in the blocking
mode.
At time step 3, the buffer has five data values, and the block returns the first four
data values in the order received and sets the Status port value to
1. The remaining data value is used in the next receipt
cycle.
At each time step, the Data port outputs data as a vector of the size that you specify in the Data size (N) parameter. The Status port outputs 0 or a nonzero value indicating whether new data is received. 0 at the Status port indicates that a valid data is received. For more information, see Outputs for Received Data.
Note
In some cases, the antivirus or firewall may block the TCP traffic. If so, configure the antivirus or firewall to allow the traffic for a specific IP port number.
Examples
Ports
Output
Parameters
More About
Version History
Introduced in R2022b



