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.

Issue

If you are having trouble connecting to or communicating with your UDP socket, follow these troubleshooting tips.

Possible Solutions

Supported Platforms

UDP is supported on these platforms:

  • Linux®

  • macOS

  • Windows®10

支持在同一platfor UDP接口万博1manbetxms as MATLAB®. For updates to the list of currently supported platforms, seeSystem Requirements.

TheconfigureMulticastfunction is only supported on Windows and not supported Linux ormacOS.

Configuration and Connection

  1. Make sure you can create your UDP object with theudpportfunction.

    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 theLocalPortproperty if you will use the object to read data. For example, create audpportobject associated with local port3533.

    u = udpport("LocalPort",3533)
    u = UDPPort with properties: IPAddressVersion: "IPV4" LocalHost: "0.0.0.0" LocalPort: 3533 NumBytesAvailable: 0 Show all properties, functions
  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.

    !ping 127.0.0.1
  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 withwriteandwritelineare valid or exist. Try!ping [destinationAddress].

    • Make sure the destination port andLocalPortare correct. The destination port is the port on the other computer to which data is sent.LocalPortis the port on the local computer that theudpportobject is bound to.

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

    SeeWrite and Read ASCII Data Over UDPandWrite and Read Binary Data Over UDPfor examples of communication over UDP and information on using properties.

See Also

Related Topics