%% Receive one UDP Packet
%%
% *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(TM), 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.

udps = dsp.UDPSender('RemoteIPPort',31000);
udpr = 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.
udps(dataSent);
datain = udpr();
bytesreceived = length(datain);
isequal(length(bytessent),length(bytesreceived))
%%
%
release(udps);
release(udpr);




%% 
% Copyright 2012 The MathWorks, Inc.