| public final class java.net DatagramPacket
|
Java SE 6 |
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.
| version | 1.46, 04/07/06 |
| since | JDK1.0 |
| Constructors | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| public | DatagramPacket(byte[] buf, int offset, int length) Details
Constructs a DatagramPacket for receiving packets of
length length, specifying an offset into the buffer.
The
| ||||||||||||||
| public | DatagramPacket(byte[] buf, int length) Details
Constructs a DatagramPacket for receiving packets of
length length.
The
| ||||||||||||||
| public | DatagramPacket(byte[] buf, int offset, int length, InetAddress address, int port) Details
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.
| ||||||||||||||
| public | DatagramPacket(byte[] buf, int offset, int length, SocketAddress address) throws SocketException Details
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.
| ||||||||||||||
| public | DatagramPacket(byte[] buf, int length, InetAddress address, int port) Details
Constructs a datagram packet for sending packets of length
length to the specified port number on the specified
host. The length argument must be less than or equal
to buf.length.
| ||||||||||||||
| public | DatagramPacket(byte[] buf, int length, SocketAddress address) throws SocketException Details
Constructs a datagram packet for sending packets of length
length to the specified port number on the specified
host. The length argument must be less than or equal
to buf.length.
| ||||||||||||||
| Properties | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| public void | setAddress(InetAddress iaddr) Details
Sets the IP address of the machine to which this datagram
is being sent.
| ||||||||||||
| public InetAddress | getAddress() Details
Returns the IP address of the machine to which this datagram is being
sent or from which the datagram was received.
| ||||||||||||
| public void | setData(byte[] buf, int offset, int length) Details
Set the data buffer for this packet. This sets the
data, length and offset of the packet.
| ||||||||||||
| public void | setData(byte[] buf) Details
Set the data buffer for this packet. With the offset of
this DatagramPacket set to 0, and the length set to
the length of buf.
| ||||||||||||
| public byte[] | getData() Details
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.
| ||||||||||||
| public void | setLength(int length) Details
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.
| ||||||||||||
| public int | getLength() Details
Returns the length of the data to be sent or the length of the
data received.
| ||||||||||||
| public int | getOffset() Details
Returns the offset of the data to be sent or the offset of the
data received.
| ||||||||||||
| public void | setPort(int iport) Details
Sets the port number on the remote host to which this datagram
is being sent.
| ||||||||||||
| public int | getPort() Details
Returns the port number on the remote host to which this datagram is
being sent or from which the datagram was received.
| ||||||||||||
| public void | setSocketAddress(SocketAddress address) Details
Sets the SocketAddress (usually IP address + port number) of the remote
host to which this datagram is being sent.
| ||||||||||||
| public SocketAddress | getSocketAddress() Details
Gets the SocketAddress (usually IP address + port number) of the remote
host that this packet is being sent to or is coming from.
| ||||||||||||
| About DocWeb · Bundles · Export · Export All | Top 10 · Statistics · Login |
| About Sun · Contact · Privacy · Terms of Use · Trademarks | Java SE 6 · Copyright © 1994-2009 Sun Microsystems, Inc.All rights reserved. Use is subject to license terms |
![]() |
![]() |
|