java::net::DatagramPacket Class Reference

Inheritance diagram for java::net::DatagramPacket:

Inheritance graph
java::lang::Objectjava::lang::Interfacejava::lang::Syncjava::lang::Lockjava::lang::ScopeAdapter
[legend]
Collaboration diagram for java::net::DatagramPacket:

Collaboration graph
java::lang::Objectjava::lang::Interfacejava::lang::ObjectRefjava::lang::Syncjava::lang::Lockjava::lang::ScopeAdapterjava::lang::Comparable
[legend]

List of all members.


Detailed Description

This class represents a datagram packet.

Datagram packets are used to implement a connectionless packet delivery service. Each message is routed from one machine to another based solely on information contained within that packet. Multiple packets sent from one machine to another might be routed differently, and might arrive in any order. Packet delivery is not guaranteed.

Author:
Pavani Diwanji

Benjamin Renaud

Yuh-Jye Chang

Version:
1.42, 01/23/03
Since:
JDK1.0

Public Member Functions

 DatagramPacket (const Ref< Array< jbyte > > &buf=0, jint offset=0, jint length=-1, const Ref< InetAddress > &address=0, jint port=-1)
 Constructs a datagram packet for sending packets of length length with offset ioffsetto the specified port number on the specified host.
 DatagramPacket (const Ref< Array< jbyte > > &buf, jint offset=0, jint length=-1, const Ref< SocketAddress > &address=0)
 Constructs a datagram packet for sending packets of length length with offset ioffsetto the specified port number on the specified host.
Ref< InetAddressgetAddress () const
 Returns the IP address of the machine to which this datagram is being sent or from which the datagram was received.
jint getPort () const
 Returns the port number on the remote host to which this datagram is being sent or from which the datagram was received.
Ref< Array< jbyte > > getData () const
 Returns the data buffer.
jint getOffset () const
 Returns the offset of the data to be sent or the offset of the data received.
jint getLength () const
 Returns the length of the data to be sent or the length of the data received.
void setData (const Ref< Array< jbyte > > &buf, jint offset=0, jint length=-1)
 Set the data buffer for this packet.
void setAddress (const Ref< InetAddress > &iaddr)
 Sets the IP address of the machine to which this datagram is being sent.
void setPort (jint iport)
 Sets the port number on the remote host to which this datagram is being sent.
void setSocketAddress (const Ref< SocketAddress > &address)
 Sets the SocketAddress (usually IP address + port number) of the remote host to which this datagram is being sent.
Ref< SocketAddressgetSocketAddress () const
 Gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.
void setLength (jint length)
 Set the length for this packet.

Protected Attributes

Ref< Array< jbyte > > buf
jint offset
jint length
Ref< InetAddressaddress
jint port

Constructor & Destructor Documentation

java::net::DatagramPacket::DatagramPacket ( const Ref< Array< jbyte > > &  buf = 0,
jint  offset = 0,
jint  length = -1,
const Ref< InetAddress > &  address = 0,
jint  port = -1 
)

Constructs a datagram packet for sending packets of length length with offset ioffsetto the specified port number on the specified host.

The length argument must be less than or equal to buf.length.

Parameters:
buf the packet data.
offset the packet data offset.
length the packet data length.
address the destination address.
port the destination port number.
See also:
java.net.InetAddress
Since:
JDK1.2

java::net::DatagramPacket::DatagramPacket ( const Ref< Array< jbyte > > &  buf,
jint  offset = 0,
jint  length = -1,
const Ref< SocketAddress > &  address = 0 
)

Constructs a datagram packet for sending packets of length length with offset ioffsetto the specified port number on the specified host.

The length argument must be less than or equal to buf.length.

Parameters:
buf the packet data.
offset the packet data offset.
length the packet data length.
address the destination socket address.
Exceptions:
IllegalArgumentException if address type is not supported
See also:
java.net.InetAddress
Since:
1.4


Member Function Documentation

Ref<InetAddress> java::net::DatagramPacket::getAddress (  )  const

Returns the IP address of the machine to which this datagram is being sent or from which the datagram was received.

Returns:
the IP address of the machine to which this datagram is being sent or from which the datagram was received.
See also:
java.net.InetAddress

setAddress(java.net.InetAddress)

jint java::net::DatagramPacket::getPort (  )  const

Returns the port number on the remote host to which this datagram is being sent or from which the datagram was received.

Returns:
the port number on the remote host to which this datagram is being sent or from which the datagram was received.
See also:
setPort(int)

Ref<Array<jbyte> > java::net::DatagramPacket::getData (  )  const

Returns the data buffer.

The data received or the data to be sent starts from the offset in the buffer, and runs for length long.

Returns:
the buffer used to receive or send data
See also:
setData(byte[], int, int)

jint java::net::DatagramPacket::getOffset (  )  const

Returns the offset of the data to be sent or the offset of the data received.

Returns:
the offset of the data to be sent or the offset of the data received.
Since:
JDK1.2

jint java::net::DatagramPacket::getLength (  )  const

Returns the length of the data to be sent or the length of the data received.

Returns:
the length of the data to be sent or the length of the data received.
See also:
setLength(int)

void java::net::DatagramPacket::setData ( const Ref< Array< jbyte > > &  buf,
jint  offset = 0,
jint  length = -1 
)

Set the data buffer for this packet.

This sets the data, length and offset of the packet.

Parameters:
buf the buffer to set for this packet
offset the offset into the data
length the length of the data and/or the length of the buffer used to receive data
Exceptions:
NullPointerException if the argument is null
See also:
getData

getOffset

getLength

Since:
JDK1.2

void java::net::DatagramPacket::setAddress ( const Ref< InetAddress > &  iaddr  ) 

Sets the IP address of the machine to which this datagram is being sent.

Parameters:
iaddr the InetAddress
Since:
JDK1.1
See also:
getAddress()

void java::net::DatagramPacket::setPort ( jint  iport  ) 

Sets the port number on the remote host to which this datagram is being sent.

Parameters:
iport the port number
Since:
JDK1.1
See also:
getPort()

void java::net::DatagramPacket::setSocketAddress ( const Ref< SocketAddress > &  address  ) 

Sets the SocketAddress (usually IP address + port number) of the remote host to which this datagram is being sent.

Parameters:
address the SocketAddress
Exceptions:
IllegalArgumentException if address is null or is a SocketAddress subclass not supported by this socket
Since:
1.4
See also:
getSocketAddress

Ref<SocketAddress> java::net::DatagramPacket::getSocketAddress (  )  const

Gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.

Returns:
the SocketAddress
Since:
1.4
See also:
setSocketAddress

void java::net::DatagramPacket::setLength ( jint  length  ) 

Set the length for this packet.

The length of the packet is the number of bytes from the packet's data buffer that will be sent, or the number of bytes of the packet's data buffer that will be used for receiving data. The length must be lesser or equal to the offset plus the length of the packet's buffer.

Parameters:
length the length to set for this packet.
Exceptions:
IllegalArgumentException if the length is negative of if the length is greater than the packet's data buffer length.
See also:
getLength

setData

Since:
JDK1.1


Member Data Documentation

Ref<Array<jbyte> > java::net::DatagramPacket::buf [protected]

jint java::net::DatagramPacket::offset [protected]

jint java::net::DatagramPacket::length [protected]

Ref<InetAddress> java::net::DatagramPacket::address [protected]

jint java::net::DatagramPacket::port [protected]


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:43 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3