Main Content

Troubleshooting TCP/IP Server 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.

Issue

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

Possible Solutions

Supported Platforms

TCP/IP is supported on these platforms:

  • Linux®

  • macOS

  • Windows® 10

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

Configuration and Connection

Make sure you can create a TCP/IP server object. You create it using the tcpserver function, which takes a port number and an optional IP address as inputs. If you do not specify an IP address, the server can accept a client connection at any valid IP address. The IP address that you specify for the server should match the IP address that the client connects to.

t = tcpserver("172.28.200.145",4000);
  1. Check that the IP address you specify is available on your machine. To see valid IP addresses for your machine, run the following command in MATLAB on Windows.

    !ipconfig
  2. If you specify a host name instead of host IP address, you can also verify that it is a valid host name by using resolvehost. If the output is empty, the specified host name is invalid.

    resolvehost("hostname","address")
    ans =
    
        '172.28.200.145'
    
    
  3. Make sure that you do not specify a port that is already in use. In addition, you can only create one server object for a given address and port combination.

  4. Make sure that your network adapter is enabled and connected.

Communication

  1. Before reading from or writing to the server object, check the Connected property to make sure that a client is connected to it. If a client has successfully connected, the value of this property is 1 (true).

    t.Connected

    The ClientAddress and ClientPort properties also provide information about the client that is connected to the server object. The value of ClientAddress should match the value of ServerAddress.

  2. Make sure the correct data type, such as int16, uint16, or double is being used with read and write. Use the same data type as the client. If reading and writing data types other than uint8 or int8, make sure the ByteOrder is correct.

See Also

Related Topics