System object: dsp.UDPReceiver
Package: dsp

Receive UDP packet


P = step (H)


P = step (H) receives one UDP packet, P, from the network. The input argument, H, is a dsp.UDPReceiver object.

    Note:   H specifies the System object™ on which to run this step method.

    The object performs an initialization the first time the step method is executed. This initialization locks nontunable properties and input specifications, such as dimensions, complexity, and data type of the input data. If you change a nontunable property or an input specification, the System object issues an error. To change nontunable properties or inputs, you must first call the release method to unlock the object.

The first time you call the step method on a UDPReceiver object, the object also allocates resources and begins listening for data. As a result, the first step call may not receive data.

Receive one UDP Packet

This example shows how to send and receive one UDP packet. Set up the objects to send and recieve UDP packets.

hsend = dsp.UDPSender;
hreceive = dsp.UDPReceiver;

Create some data to send and receive.

 dataSent = uint8(255*rand(1,128));
 bytessent = length(dataSent);

Send and receive the data. Check that the number of bytes is equal.

step(hsend, dataSent);
datain = step(hreceive);
bytesreceived = length(datain);
ans =


Was this topic helpful?