System object: dsp.UDPReceiver
Receive UDP packet
P = step (H)
P = step (H) receives
one UDP packet,
P, from the network. The input
H, is a
The object performs an initialization the first time the
The first time you call the
step method on
UDPReceiver object, the object also allocates resources
and begins listening for data. As a result, the first
may not receive data.
This example shows how to send and receive one UDP packet. Set up the objects to send and receive UDP packets.
hsend = dsp.UDPSender('RemoteIPPort',31000); hreceive = dsp.UDPReceiver('LocalIPPort',31000);
Create some data to send and receive.
dataSent = uint8(255*rand(1,128)); bytessent = length(dataSent);
Send and receive the data. Verify that the number of bytes is equal.
step(hsend, dataSent); datain = step(hreceive); bytesreceived = length(datain); isequal(length(bytessent),length(bytesreceived))
ans = 1