javax.microedition.io
Interface DatagramConnection


public interface DatagramConnection
extends Connection

This interface defines the capabilities that a datagram connection must have.

The paramter string describing the target of the connection takes the form:

{protocol}:{target}
If the {target} can't be resolved to a remote address, because it is incompletely specified, then it will be assumed to be the local address of the application, which is behaving as a "server". By "server", this means that a remote application initiates communication with the local application "server", because the local application's address is well known.

E.g. the "target" can be {host}:{port} (but is not necessarily limited to this.)

e.g. connection for accepting remote http socket connections:
http://
e.g. connection to a web server
http://www.nokia.com
e.g. another connection to a web server
http://www.mybank.com:8000
e.g. a datagram connection for accepting datagrams
datagram://:1234
e.g. a datagram connection for sending to a server:
datagram://123.456.789.12:1234

Note that the port number in "server mode" (unspecified host name) is the receiving port; and the port number in "client mode" (host name specified) is the target port. The reply to port in both cases is actually unspecified. In "server mode", it is reasonable to assume that the same port number is used for both receiving and sending. In "client mode", we must assume the reply-to port will be dynamically allocated.


Method Summary
 String getAddress()
          Get the address represented by this datagram endpoint.
 int getMaximumLength()
          Get the maximum length a datagram can be.
 int getNominalLength()
          Get the nominal length of a datagram.
 Datagram newDatagram(byte[] buf, int size)
          Make a new datagram object
 Datagram newDatagram(byte[] buf, int size, String addr)
          Make a new datagram object
 Datagram newDatagram(int size)
          Make a new datagram object automatically allocating a buffer
 void receive(Datagram dgram)
          Receive a datagram
 void send(Datagram dgram)
          Send a datagram
 
Methods inherited from interface javax.microedition.io.Connection
close, open, open
 

Method Detail

getAddress

public String getAddress()
                  throws IOException
Get the address represented by this datagram endpoint. This is the address at which implementations of this interface receives datagrams.
Returns:
address The datagram addre4ss

getMaximumLength

public int getMaximumLength()
                     throws IOException
Get the maximum length a datagram can be.
Returns:
address The length

getNominalLength

public int getNominalLength()
                     throws IOException
Get the nominal length of a datagram.
Returns:
address The length

send

public void send(Datagram dgram)
          throws IOException
Send a datagram
Parameters:
dgram - A datagram
Throws:
IOException - If an I/O error occurs

receive

public void receive(Datagram dgram)
             throws IOException
Receive a datagram
Parameters:
dgram - A datagram
Throws:
IOException - If an I/O error occurs

newDatagram

public Datagram newDatagram(int size)
                     throws IOException
Make a new datagram object automatically allocating a buffer
Returns:
A new datagram

newDatagram

public Datagram newDatagram(byte[] buf,
                            int size)
                     throws IOException
Make a new datagram object
Parameters:
buf - The buffer to be used in the datagram
Returns:
A new datagram

newDatagram

public Datagram newDatagram(byte[] buf,
                            int size,
                            String addr)
                     throws IOException
Make a new datagram object
Parameters:
buf - The buffer to be used in the datagram
addr - The address to which the datagram must go
Returns:
A new datagram