Name
DatagramConnection
Synopsis
DatagramConnection
is a Connection
that
is used to send Datagram
objects to one or more receivers.
A datagram is a sequence of bytes that is delivered together in the form of
a message. Datagrams are not guaranteed to be delivered. In addition, the
order of delivery of successive datagrams does not always match the order
in which they were sent. Since a DatagramConnection
deals in discrete messages, it does not have any associated input or output streams.
A DatagramConnection
receiver is obtained by calling the
Connector
open()
method with a
name
argument of the form
datagram://:port
, where port
is the
port number to which senders should address messages.
DatagramConnection
s created in this way can also be used
to send Datagram
s, often as responses. A
DatagramConnection
created in this way is said to
be in server mode.
A DatagramConnection
sender is obtained by supplying a
name
argument of the form
datagram://host:port
. This type of
DatagramConnection
is said to be in
client mode. The difference between server and client modes is that the port number for server mode is known in advance (and must be known by senders so that they can address messages). In client mode, the port number is dynamically allocated, and it may be different each time the client executes. The client port number will appear in the messages received by the server and can be used to address the reply message. There is currently no direct way for a client to find out the port ...
Get J2ME in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.