Main Content

TCP Send

Send data over TCP/IP network to remote host

  • TCP Send block

Libraries:
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32F4xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32F7xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32H7xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32F2xx Based Boards

Description

The TCP Send block sends data to a remote host or another hardware board over a TCP/IP network. You can set the Connection mode of the block to Server or Client. When you set Connection mode to Client, you must provide the Server IP Address and the Server IP Port on the server to which you want to send data. When you set Connection mode to Server, you must provide the Local IP Port. This Local IP Port acts as a listening port on the TCP/IP server. The server must be up and running before deploying the model that contains the TCP Send block to the target.

The block sends data either in blocking mode or in non-blocking mode. In blocking mode, the model blocks the execution while it waits for the data to be sent completely. In non-blocking mode, the model runs continuously. To set the block in blocking mode, select the Wait until data received option.

Note

When DHCP is enabled with TCP/IP or UDP blocks in the model, the code waits in an infinite loop until IP is assigned to the board. Hence, user must ensure board is connected to router, if their model has any UDP/TCP block in their model with DHCP enabled.

Examples

Ports

Input

expand all

The block accepts data specified as an N-by-1 array. The block sends this data over a TCP/IP network to the receiving host.

Data Types: int8 | uint8 | int16 | uint16 | int32 | uint32 | single | double | Boolean

Parameters

expand all

Set the block as a TCP/IP server or client.

When you set this parameter to Server, you must provide a Local IP Port. The local port acts as the listening port on the TCP/IP server.

When you set this parameter to Client, you must provide the Server IP Address and the Server IP Port on the TCP/IP server to which you want to send the data.

Specify the remote IP address of the receiving server to which the data is sent.

Dependencies

This parameter appears only when you set the Connection mode parameter to Client.

Specify the port number on the receiving server to which data is sent.

Dependencies

This parameter appears only when you set the Connection mode parameter to Client.

Specify the port number of the application from which to send the data. This local port acts as the listening port of the TCP/IP server.

  • When you select this parameter, the send operation runs in blocking mode. If the send operation of the data received in the previous time step is complete, the block accepts data from the input port. If the send operation is in progress, the block waits for the data to be sent and then it accepts data from the input port.

    A task overrun occurs if the target hardware is still waiting for the requested data to be sent when the next send operation is scheduled to begin. To fix overruns:

    • Increase the sample time of input data.

    • Reduce the length of data at the input port.

  • When you clear this parameter, the send operation runs in the non-blocking mode. If the send operation of the data received in the previous time step is still in progress, the data at the input port at the given time step is discarded.

Version History

Introduced in R2017a

See Also