Create UDP object
obj = udp('')
obj = udp('RemoteHost')
obj = udp('RemoteHost',RemotePort)
obj = udp(...,'PropertyName
',PropertyValue,...)
| The remote host. |
| The remote port. |
| A UDP property name. |
| A property value supported by |
| The UDP object. |
obj = udp('')
creates a UDP object,
obj
, not associated with a remote host.
obj = udp('RemoteHost')
creates a UDP
object associated with remote host RemoteHost
.
obj = udp('RemoteHost',RemotePort)
creates a UDP
object with remote port value, RemotePort
. The default remote
port is 9090.
obj = udp(...,'
creates
a UDP object with the specified property name/property value pairs.
If an invalid property name or property value is specified, the object
is not created.PropertyName
',PropertyValue,...)
Start the echo server and create a UDP object.
echoudp('on',4012) u = udp('127.0.0.1',4012);
Connect the UDP object to the host.
fopen(u)
Write to the host and read from the host.
fwrite(u,65:74) A = fread(u,10);
Stop the echo server and disconnect the UDP object from the host.
echoudp('off') fclose(u)
At any time, you can use the instrhelp
function
to view a complete listing of properties and functions associated
with UDP objects.
instrhelp udp
When you create a UDP object, these properties are automatically configured:
Type
is given by udp
.
Name
is given by concatenating UDP
with
the remote host name specified in the udp
function.
RemoteHost
and RemotePort
are
given by the values specified in the udp
function.
You can specify the property names and property values using
any format supported by the set
function.
For example, you can use property name/property value cell array pairs.
Additionally, you can specify property names without regard to case,
and you can make use of property name completion. For example, the
following commands are all valid.
u = udp('144.212.113.252','InputBufferSize',1024); u = udp('144.212.113.252','inputbuffersize',1024); u = udp('144.212.113.252','INPUT',1024);
The UDP object must be bound to the local socket with the fopen
function.
The default remote port is 9090. The default local host in multihome
hosts is the system's default. The LocalPort
property
defaults to a value of []
and it causes any free
local port to be used. LocalPort
is updated when fopen
is
issued. When the UDP object is constructed, the Status
property
value is closed
. Once the object is bound to the
local socket with fopen
, Status
is
configured to open
.
The maximum packet size for reading is 8192 bytes. The input
buffer can hold as many packets as defined by the InputBufferSize
property
value. You can write any data size to the output buffer. The data
will be sent in packets of at most 4096 bytes.
To get a list of options you can use on a function, press the Tab key after entering a function on the MATLAB® command line. The list expands, and you can scroll to choose a property or value. For information about using this advanced tab completion feature, see Using Tab Completion for Functions.
LocalHost
| LocalPort
| LocalPortMode
| Name
| RemoteHost
| RemotePort
| Status
| Type
| fopen