Main Content

Troubleshooting UDP Interface

User Datagram Protocol (UDP or UDP/IP) is a transport protocol layered on top of the Internet Protocol (IP). UDP is a connectionless protocol. An application using UDP prepares a packet and sends it to the receiver's address without first checking to see if the receiver is ready to receive a packet. If the receiving end is not ready to receive a packet, the packet is lost.


If you are having trouble connecting to or communicating with your UDP socket, follow these troubleshooting tips. All of these steps also apply for troubleshooting the UDP Explorer app.

Possible Solutions

Supported Platforms

UDP is supported on these platforms:

  • Linux®

  • macOS

  • Windows® 10

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

The configureMulticast function is only supported on Windows and not supported Linux or macOS.

Configuration and Connection

  1. Make sure you can create your UDP object with the udpport function.

    Although UDP is a stateless connection, creating a UDP object with an invalid local host or local port generates an error. Specifying a local port that is in use elsewhere or a port with port sharing disabled also generates an error. You can configure property values during object creation, such as the LocalPort property if you will use the object to read data. For example, create a udpport object associated with local port 3533.

    u = udpport("LocalPort",3533)
    u = 
      UDPPort with properties:
         IPAddressVersion: "IPV4"
                LocalHost: ""
                LocalPort: 3533
        NumBytesAvailable: 0
      Show all properties, functions

    If you are using the UDP Explorer app, you specify the local port to bind to after clicking Configure UDP Socket. Click Confirm Parameters to bind to a UDP socket.

    UDP Explorer app with connection parameters.

  2. If the computer or host does not exist, you will get a warning. You can try to ping the computer to see if it is responding.

  3. When you have connected, you can communicate with your device. If sending and receiving does not work, you can check the following:

    • Make sure the destination address and destination port parameters for sending data with write and writeline are valid or exist. Try !ping [destinationAddress].

    • Make sure the destination port and LocalPort are correct. The destination port is the port on the other computer to which data is sent. LocalPort is the port on the local computer that the udpport object is bound to.

    • UDP is not a reliable protocol and packets can be dropped. You may need to try sending or receiving multiple times.

    See Write and Read ASCII Data Over UDP and Write and Read Binary Data Over UDP for examples of communication over UDP and information on using properties.

See Also


Related Topics