The event types and associated callback properties supported by TCP/IP and UDP objects are listed below.
TCP/IP and UDP Event Types and Callback Properties
The datagram-received event is described below. For a description of the other event types, refer to Event Types and Callback Properties.
A datagram-received event is generated immediately after a complete datagram is received in the input buffer.
This event executes the callback function specified for the
It can be generated for both synchronous and asynchronous read operations.
You can respond to event information in a callback function
or in a record file. Event information stored in a callback function
uses two fields:
Type field contains the event type, while the
contains event-specific information. As described in Creating and Executing Callback Functions, these two fields
are associated with a structure that you define in the callback function
header. Refer to Debugging: Recording Information to Disk to learn
about storing event information in a record file.
The event types and the values for the
are given below.
TCP/IP and UDP Event Information
IP address string
Number of bytes received as double
Port number of sender as double
An error string
Data field values are described below.
AbsTime is defined for all events, and indicates
the absolute time the event occurred. The absolute time is returned
using the MATLAB® Command window
DatagramAddress is the IP address of the
DatagramLength is the length of the datagram in bytes.
DatagramPort is the sender's port number
from which the datagram originated.
Message is used by the error event to store
the descriptive message that is generated when an error occurs.
This example extends Communicating Between Two Hosts to
include a datagram received callback. The callback function is
instrcallback, which displays information
to the command line indicating that a datagram has been received.
The following command configures the callback for the UDP object
u2.DatagramReceivedFcn = @instrcallback;
When a datagram is received, the following message is displayed.
DatagramReceived event occurred at 10:26:20 for the object: UDP-doetom.dhpc. 25 bytes were received from address 192.168.1.12, port 8844.