|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.net.DatagramPacket
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 Summary | |
DatagramPacket(byte[] buf,
int length)
Constructs a DatagramPacket for receiving packets of
length length . |
|
DatagramPacket(byte[] buf,
int length,
InetAddress address,
int port)
Constructs a datagram packet for sending packets of length length to the specified port number on the specified
host. |
|
DatagramPacket(byte[] buf,
int offset,
int length)
Constructs a DatagramPacket for receiving packets of
length length , specifying an offset into the buffer. |
|
DatagramPacket(byte[] buf,
int offset,
int length,
InetAddress address,
int port)
Constructs a datagram packet for sending packets of length length with offset ioffset to the
specified port number on the specified host. |
Method Summary | |
InetAddress |
getAddress()
Returns the IP address of the machine to which this datagram is being sent or from which the datagram was received. |
byte[] |
getData()
Returns the data received or the data to be sent. |
int |
getLength()
Returns the length of the data to be sent or the length of the data received. |
int |
getOffset()
Returns the offset of the data to be sent or the offset of the data received. |
int |
getPort()
Returns the port number on the remote host to which this datagram is being sent or from which the datagram was received. |
void |
setAddress(InetAddress iaddr)
|
void |
setData(byte[] buf)
Set the data buffer for this packet. |
void |
setData(byte[] buf,
int offset,
int length)
Set the data buffer for this packet. |
void |
setLength(int length)
Set the length for this packet. |
void |
setPort(int iport)
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public DatagramPacket(byte[] buf, int offset, int length)
DatagramPacket
for receiving packets of
length length
, specifying an offset into the buffer.
The length
argument must be less than or equal to
buf.length
.
buf
- buffer for holding the incoming datagram.offset
- the offset for the bufferlength
- the number of bytes to read.public DatagramPacket(byte[] buf, int length)
DatagramPacket
for receiving packets of
length length
.
The length
argument must be less than or equal to
buf.length
.
buf
- buffer for holding the incoming datagram.length
- the number of bytes to read.public DatagramPacket(byte[] buf, int offset, int length, InetAddress address, int port)
length
with offset ioffset
to the
specified port number on the specified host. The
length
argument must be less than or equal to
buf.length
.buf
- the packet data.offset
- the packet data offset.length
- the packet data length.addr
- the destination address.port
- the destination port number.InetAddress
public DatagramPacket(byte[] buf, int length, InetAddress address, int port)
length
to the specified port number on the specified
host. The length
argument must be less than or equal
to buf.length
.buf
- the packet data.length
- the packet length.addr
- the destination address.port
- the destination port number.InetAddress
Method Detail |
public InetAddress getAddress()
InetAddress
public int getPort()
public byte[] getData()
public int getOffset()
public int getLength()
public void setData(byte[] buf, int offset, int length)
buf
- the buffer to set for this packetoffset
- the offset into the datalength
- the length of the datagetData()
,
getOffset()
,
getLength()
public void setAddress(InetAddress iaddr)
public void setPort(int iport)
public void setData(byte[] buf)
buf
- the buffer to set for this packet.getLength()
,
getData()
public void setLength(int length)
length
- the length to set for this packet.getLength()
,
setData(byte[], int, int)
|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |