Java java.net DatagramPacket fields, constructors, methods, implement or subclass

Example usage for Java java.net DatagramPacket fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for java.net DatagramPacket.

The text is from its open source code.

Constructor

DatagramPacket(byte buf[], int length)
Constructs a DatagramPacket for receiving packets of length length .
DatagramPacket(byte buf[], int offset, int length, SocketAddress address)
Constructs a datagram packet for sending packets of length length with offset offset to the specified port number on the specified host.
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 length, SocketAddress address)
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, InetAddress address, int port)
Constructs a datagram packet for sending packets of length length with offset offset to the specified port number on the specified host.

Method

InetAddressgetAddress()
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 buffer.
intgetLength()
Returns the length of the data to be sent or the length of the data received.
intgetOffset()
Returns the offset of the data to be sent or the offset of the data received.
intgetPort()
Returns the port number on the remote host to which this datagram is being sent or from which the datagram was received.
SocketAddressgetSocketAddress()
Gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.
voidsetAddress(InetAddress iaddr)
Sets the IP address of the machine to which this datagram is being sent.
voidsetData(byte[] buf)
Set the data buffer for this packet.
voidsetData(byte[] buf, int offset, int length)
Set the data buffer for this packet.
voidsetLength(int length)
Set the length for this packet.
voidsetPort(int iport)
Sets the port number on the remote host to which this datagram is being sent.
voidsetSocketAddress(SocketAddress address)
Sets the SocketAddress (usually IP address + port number) of the remote host to which this datagram is being sent.