All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.net.DatagramPacket

java.lang.Object
   |
   +----java.net.DatagramPacket

public final class DatagramPacket
extends Object
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.


Constructor Index

 o DatagramPacket(byte[], int)
Constructs a DatagramPacket for receiving packets of length ilength.
 o DatagramPacket(byte[], int, InetAddress, int)
Constructs a datagram packet for sending packets of length ilength to the specified port number on the specified host.

Method Index

 o getAddress()
Returns the IP address of the machine to which this datagram is being sent or from which the datagram was received.
 o getData()
Returns the data received or the data to be sent.
 o getLength()
Returns the length of the data to be sent or the length of the data received.
 o getPort()
Returns the port number on the remote host to which this datagram is being sent or from which the datagram was received.
 o setAddress(InetAddress)
 o setData(byte[])
 o setLength(int)
 o setPort(int)

Constructors

 o DatagramPacket
    method DatagramPacket(ibuf=byte[], -
                          ilength=int) public 
Constructs a DatagramPacket for receiving packets of length ilength.

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

Parameters:
ibuf - buffer for holding the incoming datagram.
ilength - the number of bytes to read.
 o DatagramPacket
    method DatagramPacket(ibuf=byte[], -
                          ilength=int, -
                          iaddr=InetAddress, -
                          iport=int) public 
Constructs a datagram packet for sending packets of length ilength to the specified port number on the specified host. The length argument must be less than or equal to ibuf.length.

Parameters:
ibuf - the packet data.
ilength - the packet length.
iaddr - the destination address.
iport - the destination port number.
See Also:
InetAddress

Methods

 o getAddress
    method getAddress() returns InetAddress public    protect 
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:
InetAddress
 o getPort
    method getPort() returns int public    protect 
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.
 o getData
    method getData() returns byte[] public    protect 
Returns the data received or the data to be sent.

Returns:
the data received or the data to be sent.
 o getLength
    method getLength() returns int public    protect 
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.
 o setAddress
    method setAddress(iaddr=InetAddress)  public    protect 
 o setPort
    method setPort(iport=int)  public    protect 
 o setData
    method setData(ibuf=byte[])  public    protect 
 o setLength
    method setLength(ilength=int)  public    protect 

All Packages  Class Hierarchy  This Package  Previous  Next  Index