DthingApi
Public Member Functions | List of all members
java.net.DatagramPacket Class Reference

Public Member Functions

 DatagramPacket (byte[] data, int length)
 
 DatagramPacket (byte[] data, int offset, int length)
 
 DatagramPacket (byte[] data, int offset, int length, InetAddress host, int aPort)
 
 DatagramPacket (byte[] data, int length, InetAddress host, int port)
 
synchronized InetAddress getAddress ()
 
synchronized byte [] getData ()
 
synchronized int getLength ()
 
synchronized int getOffset ()
 
synchronized int getPort ()
 
synchronized void setAddress (InetAddress addr)
 
synchronized void setData (byte[] data, int offset, int byteCount)
 
synchronized void setData (byte[] buf)
 
synchronized void setLength (int length)
 
synchronized void setPort (int aPort)
 
 DatagramPacket (byte[] data, int length, SocketAddress sockAddr) throws SocketException
 
 DatagramPacket (byte[] data, int offset, int length, SocketAddress sockAddr) throws SocketException
 
synchronized SocketAddress getSocketAddress ()
 
synchronized void setSocketAddress (SocketAddress sockAddr)
 

Detailed Description

This class represents a datagram packet which contains data either to be sent or received through a

DatagramSocket

. It holds additional information such as its source or destination host.

See also
DatagramSocket

Constructor & Destructor Documentation

◆ DatagramPacket() [1/6]

java.net.DatagramPacket.DatagramPacket ( byte []  data,
int  length 
)
inline

Constructs a new

object to receive data up to

length

bytes.

Parameters
dataa byte array to store the read characters.
lengththe length of the data buffer.

◆ DatagramPacket() [2/6]

java.net.DatagramPacket.DatagramPacket ( byte []  data,
int  offset,
int  length 
)
inline

Constructs a new

object to receive data up to

length

bytes with a specified buffer offset.

Parameters
dataa byte array to store the read characters.
offsetthe offset of the byte array where the bytes is written.
lengththe length of the data.

◆ DatagramPacket() [3/6]

java.net.DatagramPacket.DatagramPacket ( byte []  data,
int  offset,
int  length,
InetAddress  host,
int  aPort 
)
inline

Constructs a new

object to send data to the port

aPort

of the address

host

. The

length

must be lesser than or equal to the size of

data

. The first

length

bytes from the byte array position

offset

are sent.

Parameters
dataa byte array which stores the characters to be sent.
offsetthe offset of
data
where to read from.
lengththe length of data.
hostthe address of the target host.
aPortthe port of the target host.

◆ DatagramPacket() [4/6]

java.net.DatagramPacket.DatagramPacket ( byte []  data,
int  length,
InetAddress  host,
int  port 
)
inline

Constructs a new

object to send data to the port

aPort

of the address

host

. The

length

must be lesser than or equal to the size of

data

. The first

length

bytes are sent.

Parameters
dataa byte array which stores the characters to be sent.
lengththe length of data.
hostthe address of the target host.
portthe port of the target host.

◆ DatagramPacket() [5/6]

java.net.DatagramPacket.DatagramPacket ( byte []  data,
int  length,
SocketAddress  sockAddr 
) throws SocketException
inline

Constructs a new

object to send data to the address

sockAddr

. The

length

must be lesser than or equal to the size of

data

. The first

length

bytes of the data are sent.

Parameters
datathe byte array to store the data.
lengththe length of the data.
sockAddrthe target host address and port.
Exceptions
SocketExceptionif an error in the underlying protocol occurs.

◆ DatagramPacket() [6/6]

java.net.DatagramPacket.DatagramPacket ( byte []  data,
int  offset,
int  length,
SocketAddress  sockAddr 
) throws SocketException
inline

Constructs a new

object to send data to the address

sockAddr

. The

length

must be lesser than or equal to the size of

data

. The first

length

bytes of the data are sent.

Parameters
datathe byte array to store the data.
offsetthe offset of the data.
lengththe length of the data.
sockAddrthe target host address and port.
Exceptions
SocketExceptionif an error in the underlying protocol occurs.

Member Function Documentation

◆ getAddress()

synchronized InetAddress java.net.DatagramPacket.getAddress ( )
inline

Gets the sender or destination IP address of this datagram packet.

Returns
the address from where the datagram was received or to which it is sent.

◆ getData()

synchronized byte [] java.net.DatagramPacket.getData ( )
inline

Gets the data of this datagram packet.

Returns
the received data or the data to be sent.

◆ getLength()

synchronized int java.net.DatagramPacket.getLength ( )
inline

Gets the length of the data stored in this datagram packet.

Returns
the length of the received data or the data to be sent.

◆ getOffset()

synchronized int java.net.DatagramPacket.getOffset ( )
inline

Gets the offset of the data stored in this datagram packet.

Returns
the position of the received data or the data to be sent.

◆ getPort()

synchronized int java.net.DatagramPacket.getPort ( )
inline

Gets the port number of the target or sender host of this datagram packet.

Returns
the port number of the origin or target host.

◆ getSocketAddress()

synchronized SocketAddress java.net.DatagramPacket.getSocketAddress ( )
inline

Gets the host address and the port to which this datagram packet is sent as a

SocketAddress

object.

Returns
the SocketAddress of the target host.

◆ setAddress()

synchronized void java.net.DatagramPacket.setAddress ( InetAddress  addr)
inline

Sets the IP address of the target host.

Parameters
addrthe target host address.

◆ setData() [1/2]

synchronized void java.net.DatagramPacket.setData ( byte []  data,
int  offset,
int  byteCount 
)
inline

Sets the data buffer for this datagram packet.

◆ setData() [2/2]

synchronized void java.net.DatagramPacket.setData ( byte []  buf)
inline

Sets the data buffer for this datagram packet. The length of the datagram packet is set to the buffer length.

Parameters
bufthe buffer to store the data.

◆ setLength()

synchronized void java.net.DatagramPacket.setLength ( int  length)
inline

Sets the length of the datagram packet. This length plus the offset must be lesser than or equal to the buffer size.

Parameters
lengththe length of this datagram packet.

◆ setPort()

synchronized void java.net.DatagramPacket.setPort ( int  aPort)
inline

Sets the port number of the target host of this datagram packet.

Parameters
aPortthe target host port number.

◆ setSocketAddress()

synchronized void java.net.DatagramPacket.setSocketAddress ( SocketAddress  sockAddr)
inline

Sets the

SocketAddress

for this datagram packet.

Parameters
sockAddrthe SocketAddress of the target host.

The documentation for this class was generated from the following file: