Send/Reveive data using UDP to/from Matlab
OpenEdge ABL
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


% This script enables the user to establish  UDP communications with another
% application, either on the same or a remote machine. The same script can
% also be used to exchange data between two separate instantiations of
% Matlab on the same or remote machine.  
% udp_socket('SEND',PORT,HOST,MSSG) sends a message to the specified port and
% host. HOST can be either a hostname (e.g., '') or a string
% representation of an IP address (e.g., ''). Port is an
% integer port number between 1025 and 65535. The specified port must be
% open in the receiving machine's firewall.
% MSSG = udp_socket('RECEIVE',PORT,PKTLGNTH) receives a message over the
% specified port. PKTLGNTH should be set to the maximum expected
% message length to be received in the UDP packet; if too small, the
% message will be truncated.
% MSSG = udp_socket('RECEIVE',PORT,PKTLGNTH,TIMEOUT) attempts to receive a
% message but times out after TIMEOUT milliseconds. If TIMEOUT is not
% specified, as in the previous example, a default value of
% 5000 milliseconds is used.
% [MSSG,SOURCEHOST] = udp_socket('RECEIVE',...) returns a string representation
% of the originating host's IP address, in addition to the received
% message. 
% Messages sent by udp_socket.m are in int8 format. The int8.m function can be
% used to convert integers or characters to the correct format (use
% double.m or char.m to convert back after the datagram is received). 
% Non-integer values can be converted to int8 format using typecast.m (use
% typecast.m to convert back).
% e.g.,   mssg = udp_socket('receive',9570,10); char(mssg')
%         udp_socket('send',9570,'',int8('Hello World!'))         
% e.g.,   [mssg,sourceHost] = udp_socket('receive',9750,10,5000)
%         udp_socket('send',9750,'',int8([1 2 3 4]))
% e.g.,   mssg = udp_socket('receive',9750,200); typecast(mssg,'double')
%         udp_socket('send',9750,'localhost',typecast([1.1 2.2 3.3],'int8'))

% Developed in Matlab (R2011b) on OSX 10.7.
% Yash Mulgaonkar (, January 15, 2012