Main Content

UDP Interface

Communication using the UDP protocol

User Datagram Protocol (UDP) is a transport protocol layered on top of the Internet Protocol (IP). Use the UDP interface for reading and writing both binary data and ASCII data. You can read and write to servers, computers, instruments, and use applications such as streaming video and audio, point-of-sale systems, and other business applications.

Functions

expand all

udpportConnect to UDP socket
echoudpStart or stop echo UDP server
configureTerminatorSet terminator for ASCII string communication with UDP socket
configureCallbackSet callback function and trigger condition for communication with UDP socket
configureMulticastSet multicast properties for communication with UDP socket
readRead data from UDP socket
readlineRead line of ASCII string data from UDP socket
writeWrite data to UDP socket
writelineWrite line of ASCII data to UDP socket
flushClear UDP socket buffers

Blocks

Query InstrumentQuery or read instrument data
To InstrumentSend simulation data to instrument
UDP ReceiveReceive data over UDP network from specified remote machine
UDP SendSend data over UDP network to specified remote machine

Topics

Create a UDP Object and View Properties

Create a UDP object to establish a connection between MATLAB® and the remote host.

UDP Communication Between Two Hosts

These are the minimum steps required to communicate between two hosts over UDP.

Write and Read ASCII Data Over UDP

Explore ASCII write and read operations with a UDP object.

Write and Read Binary Data Over UDP

Explore binary write and read operations with a UDP object.

Use Callbacks for UDP Communication

Enhance UDP communication by executing a callback function when a specified event occurs.

TCP/IP and UDP Comparison

Compare the TCP/IP and UDP protocols to determine which to use.

Transition Your Code to udpport Interface

Connect to a UDP socket using udpport instead of udp.

Troubleshooting

Troubleshooting UDP Interface

Troubleshoot the UDP interface.

Resolve UDP Port Warning: Unable to Read Any Data

Troubleshoot when you receive no data and you get the warning message: 'udpport' unable to read any data.

Resolve UDP Port Warning: Unable to Read All Data

Troubleshoot when you receive some data and you get the warning message: 'udpport' unable to read all requested data.

Featured Examples