Main Content

TCP Client

Configure TCP client

Since R2020b

  • TCP Client block

Libraries:
Simulink Real-Time / IP

Description

The TCP Client block configures a TCP client.

The parameters Client IP address and Client port are optional. The Client IP address applies when the block executes in a real-time application on a target computer or in a model simulation on a development computer. If your model is running in Simulink® on the development computer, you can use this block to transmit data to a remote device. In this case, the Windows® operating system determines the network connection.

Ports

Input

expand all

If Enable is greater than zero, the block connects to the Ethernet device. Otherwise, the block does not connect to the Ethernet device.

Output

expand all

The status value is one of:

  • 0 — Not connected

  • 1 — Connected

As a best practice, connect the Status output of a TCP configure block to the Enable input of the associated TCP Send and TCP Receive blocks.

Parameters

expand all

Dependency

When you select this parameter, it deactivates the Client IP address parameter and excludes the ports 1 through 1023 and 5500 through 5560 from use by TCP.

Programmatic Use

Block Parameter: useHostTargetConn

Enter the IP address of the server to which you want to connect the client.

Programmatic Use

Block Parameter: remoteAddress

Enter the port number of the server to which you want to connect the client.

Ports 1 through 1023 and 5500 through 5560 are reserved for Simulink Real-Time communications.

Programmatic Use

Block Parameter: remotePort

Advanced Parameters

If you are using a dedicated Ethernet card, this value must match the Local IP Address parameter in the IP Config block for the network interface. The default value for the Client IP address field is no value. This empty field means that the operating system chooses the Client IP address for TCP transmission.

Programmatic Use

Block Parameter: clientAddress

The combination of Client IP address and Client local port must be unique.

Ports 1 through 1023 and 5500 through 5560 are reserved for Simulink Real-Time communications. Values '-1', '0', or 'empty' mean that the block transmits data by using any available port.

Programmatic Use

Block Parameter: clientPort

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2020b

expand all

See Also