Class java.net.DatagramPacket
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.net.DatagramPacket

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.

Version:
1.13, 07/01/98
Author:
Pavani Diwanji
Since:
JDK1.0

Constructor Index

 o java.net.DatagramPacket(byte[], int)
Constructs a DatagramPacket for receiving packets of length ilength.
 o java.net.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
public DatagramPacket(byte ibuf,
                      int ilength)
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.
Since:
JDK1.0
 o DatagramPacket
public DatagramPacket(byte ibuf,
                      int ilength,
                      InetAddress iaddr,
                      int iport)
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.
Since:
JDK1.0
See Also:
InetAddress

Methods

 o getAddress
public synchronized java.net.InetAddress getAddress()
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.
Since:
JDK1.0
See Also:
InetAddress
 o getData
public synchronized byte[] getData()
Returns the data received or the data to be sent.

Returns:
the data received or the data to be sent.
Since:
JDK1.0
 o getLength
public synchronized int getLength()
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.
Since:
JDK1.0
 o getPort
public synchronized int getPort()
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.
Since:
JDK1.0
 o setAddress
public synchronized void setAddress(InetAddress iaddr)

Since:
JDK1.1
 o setData
public synchronized void setData(byte ibuf)

Since:
JDK1.1
 o setLength
public synchronized void setLength(int ilength)

Since:
JDK1.1
 o setPort
public synchronized void setPort(int iport)

Since:
JDK1.1

All Packages  Class Hierarchy  This Package  Previous  Next  Index