Main Content

Troubleshooting TCP/IP Client Interface

Transmission Control Protocol (TCP) is a transport protocol layered on top of the Internet Protocol (IP) and is one of the most highly used networking protocols. You can use network socket communication to connect to remote hosts to read and write data.

Issue

If you are having trouble connecting to or communicating with your remote host, try these troubleshooting tips.

Possible Solutions

Supported Platforms

TCP/IP is supported on these platforms:

  • Linux®

  • macOS

  • Windows®10

The TCP/IP client interface is supported on the same platforms as MATLAB®. For updates to the list of currently supported platforms, seeSystem Requirements.

Configuration and Connection

  1. Make sure you can create your TCP/IP client object. You create a client object with thetcpclient函数,它要求uires the name of the remote host as an input argument. You also need to specify the remote port value.

    Each client object is associated with one instrument. For example, to create a client object for a Sony/Tektronix®AWG520 Arbitrary Waveform Generator, you use the remote host name of the instrument and the port number, which can be found in the instrument documentation.

    t = tcpclient("sonytekawg.yourdomain.com",4000);
  2. After you connect to the device, you can communicate with it. If sending and receiving does not work, you can check the following:

    • Make sure the data is being sent in the format expected by the server.

    • If you connect to a web server, you might need to send HTTPgetorpostcommands. You can also use theurlreadorwebreadfunctions to communicate with web servers.

    • Many TCP/IP servers expect header information inside the TCP/IP packet.

    SeeWrite and Read Data over TCP/IP Interfacefor an example of communication over TCP/IP.

VISA-TCP/IP Communication

You can also use thevisadevinterface with a VISA-TCP/IP resource name instead of thetcpclientinterface for TCP/IP communication with instruments.

Incorrect Data Type

Make sure the correct data type—for exampleint16,uint16,double—is being used withreadandwrite. Use the same data type as the instrument. If reading and writing data types other thanuint8orint8, make sure theByteOrderis correct.

See Also

Related Topics