|
SunSPOT API V6.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.squawk.io.ConnectionBase
com.sun.spot.peripheral.RadioConnectionBase
com.sun.spot.io.j2me.udp.UDPConnection
public class UDPConnection
This class provides the "udp" protocol for accessing a node using datagrams.
It is an implementor of DatagramConection
| Field Summary |
|---|
| Fields inherited from class com.sun.spot.peripheral.RadioConnectionBase |
|---|
DEFAULT_TIMEOUT |
| Constructor Summary | |
|---|---|
UDPConnection()
DO NOT USE THIS CONSTRUCTOR - connections should be created using Connector.open(...) |
|
UDPConnection(String addr,
int portNo,
boolean isServer,
boolean timeouts)
DO NOT USE THIS CONSTRUCTOR - connections should be created using Connector.open(...) |
|
| Method Summary | |
|---|---|
void |
close()
Close |
short |
getLocalPort()
|
int |
getMaximumLength()
Get the maximum length a datagram can be. |
int |
getNominalLength()
Get the nominal length of a datagram. |
Inet6Address |
getRemoteAddress()
|
short |
getRemotePort()
|
protected boolean |
isBroadcast()
|
protected boolean |
isServer()
|
Datagram |
newDatagram(byte[] buf,
int size)
Create a new datagram object. |
Datagram |
newDatagram(byte[] buf,
int size,
String addr)
Make a new datagram object. |
Datagram |
newDatagram(int size)
Create a new datagram object. |
Datagram |
newDatagram(int size,
String addr)
Create a new datagram object. |
Connection |
open(String arg0,
String arg1,
int arg2,
boolean arg3)
Open a connection to a target. |
void |
receive(Datagram dgram)
Receive a datagram. |
protected UDPPacket |
receivePacket()
|
protected UDPPacket |
receivePacket(long timeout)
|
void |
send(Datagram dgram)
Send a datagram. |
| Methods inherited from class com.sun.spot.peripheral.RadioConnectionBase |
|---|
getTimeout, setTimeout |
| Methods inherited from class com.sun.squawk.io.ConnectionBase |
|---|
openDataInputStream, openDataOutputStream, openInputStream, openOutputStream |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public UDPConnection(String addr,
int portNo,
boolean isServer,
boolean timeouts)
UDPConnection object.
addr - The IPv6 address of the remote end of the connection. If this is not specified
then this end of the connection is a server connection.portNo - The IPv6 TCP port number of the remote end of the connection. If this is a server
connection, this port number is the port number of this end of the server connection.isServer - Defines whether this is a server side connection.timeouts - The default timeout for socket operations.public UDPConnection()
| Method Detail |
|---|
public void close()
throws IOException
ConnectionBase
close in interface Connectionclose in class ConnectionBaseIOException - If an I/O error occurspublic int getMaximumLength()
DatagramConnectionnewDatagram method, and the
maximum size of the datagram that can be sent
or received.
getMaximumLength in interface DatagramConnectionpublic int getNominalLength()
DatagramConnection
getNominalLength in interface DatagramConnection
public void send(Datagram dgram)
throws NoAckException,
ChannelBusyException,
NoRouteToHostException,
NoMeshLayerAckException,
SocketException
DatagramConnectionDatagram object includes
the information indicating the data to be sent, its length,
and the address of the receiver. The method sends length
bytes starting at the current offset of the
Datagram object, where length
and offset are internal state variables
of the Datagram object.
send in interface DatagramConnectiondgram - A datagram.
NoAckException
ChannelBusyException
NoRouteToHostException
NoMeshLayerAckException
SocketException
public void receive(Datagram dgram)
throws IOException
DatagramConnectionDatagram object is filled with
the data received, starting at the location determined by
the offset state variable, and the data is
ready to be read using the methods of the
DataInput interface.
This method blocks until a datagram is received. The internal
length state variable in the Datagram
object contains the length of the received datagram. If the
received data is longer than the length of the internal buffer
minus offset, data is truncated.
This method does not change the internal read/write state
variable of the Datagram object. Use method
Datagram.reset to change the pointer before
reading if necessary.
receive in interface DatagramConnectiondgram - A datagram.
IOException - If an I/O error occurs.public Datagram newDatagram(int size)
DatagramConnection
newDatagram in interface DatagramConnectionsize - The size of the buffer needed
for the datagram
public Datagram newDatagram(int size,
String addr)
DatagramConnection
newDatagram in interface DatagramConnectionsize - The size of the buffer needed
for the datagramaddr - The I/O address to which the datagram
will be sent
public Datagram newDatagram(byte[] buf,
int size)
DatagramConnection
newDatagram in interface DatagramConnectionbuf - The buffer to be used for the datagramsize - The size of the buffer needed
for the datagram
public Datagram newDatagram(byte[] buf,
int size,
String addr)
DatagramConnection
newDatagram in interface DatagramConnectionbuf - The buffer to be used for the datagramsize - The size of the buffer needed
for the datagramaddr - The I/O address to which the datagram
will be sent
protected boolean isBroadcast()
protected boolean isServer()
public Connection open(String arg0,
String arg1,
int arg2,
boolean arg3)
throws IOException
ConnectionBase
open in class ConnectionBasearg0 - The URL protocolarg1 - The URL for the connectionarg2 - The access modearg3 - A flag to indicate that the caller
wants timeout exceptions
ConnectionNotFoundException - If the connection cannot
be found.
IOException - If some other kind of I/O error occurs.protected UDPPacket receivePacket(long timeout)
protected UDPPacket receivePacket()
public short getLocalPort()
public short getRemotePort()
public Inet6Address getRemoteAddress()
|
SunSPOT API V6.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||