P = step (H)
Starting in R2016b, instead of using the
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. To prevent the loss of packets, call the
on the object before the first call to the
Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent
step syntax. For
dsp.UDPReceiver System object™, myObject() becomes step(myObject). For all other objects, myObject(x) becomes step(myObject,x).
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.
hsend(dataSent); datain = hreceive(); bytesreceived = length(datain); isequal(length(bytessent),length(bytesreceived))
ans = logical 1