TCP Client

Overview

The program SR_TcpClient implements the program code for the TCP client functionality. For control and monitoring of this functionality, the visualization screen VisuTcpClient is provided in the example project.

The variables which link the visualization with the program code are defined in the global variable list GVL_VisuTcpClient.

Connecting to the TCP Server

In the visualization, enter the IP address and the port number of the TCP server you want to connect to. To establish the connection to this TCP server, click the Connect & Send button in the visualization.

Whether a connection to the TCP server is encrypted using TLS (Transport Layer Security) and the certificate sent by the TCP server to prove that the identity is verified depends on the controller used.

Sending Data to the TCP Server

After the TCP client has established a connection to the TCP server, a data packet is sent to the server. You can modify the text message in the visualization. The TCP server implemented in this example application only accepts the message GetTimestamp.

Receiving the Response from the TCP Server

After the TCP client has sent a data packet to the TCP server, a response is expected within a certain time. You can set the allowed time for receiving the response in the visualization.

By sending the text message GetTimestamp, the client expects the system time of the controller running the TCP server as response.

The response is verified using the transmission ID. The transmission ID of the received data packet must be equal to the transmission ID of the sent data packet. If a different transmission ID is received, the received data is rejected and a diagnostic message is generated.

Terminating the Connection to the TCP Server

The connection is terminated by the TCP client if one of the following conditions applies:

oA response has been received from the TCP server (valid or not).

oThe timeout has been reached without receiving a response.