activemq-cpp-3.6.0
decaf::net::DatagramPacket Class Reference

Class that represents a single datagram packet. More...

#include <src/main/decaf/net/DatagramPacket.h>

Public Member Functions

 DatagramPacket (unsigned char *bytes, int size, int length)
 Creates a new DatagramPacket for use in receiving a packet of the given length.
 DatagramPacket (unsigned char *bytes, int size, int offset, int length)
 Creates a new DatagramPacket for use in receiving a packet of the given length starting at the specified offset into the buffer.
 DatagramPacket (unsigned char *bytes, int size, int offset, int length, const InetAddress &address, int port)
 Creates a new DatagramPacket for use in sending a packet of the given length starting at the specified offset into the buffer to the specified host on the specified port.
 DatagramPacket (unsigned char *bytes, int size, int length, const InetAddress &address, int port)
 Creates a new DatagramPacket for use in sending a packet of the given length to the specified host on the specified port.
 DatagramPacket (unsigned char *bytes, int size, int length, const SocketAddress &address)
 Creates a new DatagramPacket for use in sending a packet of the given length into the buffer to the specified socket address.
 DatagramPacket (unsigned char *bytes, int size, int offset, int length, const SocketAddress &address)
 Creates a new DatagramPacket for use in sending a packet of the given length starting at the specified offset into the buffer to the specified socket address.
virtual ~DatagramPacket ()
InetAddressgetAddress () const
void setAddress (const InetAddress &address)
 Sets the IP address of the machine to which this datagram is being sent.
SocketAddressgetSocketAddress () const
 Gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.
void setSocketAddress (const SocketAddress &address)
 Sets the SocketAddress (usually IP address + port number) of the remote host to which this datagram is being sent.
int getPort () const
void setPort (int port)
 Sets the port number on the remote host to which this datagram is being sent.
int getOffset () const
void setOffset (int offset)
 Sets the offset into the data buffer where data to sent is to be read from or where the data that is received should start writing to.
int getLength () const
void setLength (int length)
 Set the length for this packet.
unsigned char * getData () const
int getSize () const
void setData (unsigned char *buffer, int size)
 Set the data buffer for this packet.
void setData (unsigned char *buffer, int size, int offset, int length)
 Set the data buffer for this packet.

Detailed Description

Class that represents a single datagram packet.

Datagrams are sent in packets from machine to machine and can each be routed differently and can arrive in any order. Delivery of a packet is not guaranteed.

Since
1.0

Constructor & Destructor Documentation

decaf::net::DatagramPacket::DatagramPacket ( unsigned char *  bytes,
int  size,
int  length 
)

Creates a new DatagramPacket for use in receiving a packet of the given length.

Parameters
bytesThe array of bytes to hold the incoming datagram buffer.
sizeThe size of the supplied byte array.
lengthThe number of byte to read starting at the supplied offset.
Exceptions
NullPointerExceptionif the pointer to the buffer is NULL.
IndexOutOfBoundsExceptionif the number of bytes to read exceeds the buffer size.
decaf::net::DatagramPacket::DatagramPacket ( unsigned char *  bytes,
int  size,
int  offset,
int  length 
)

Creates a new DatagramPacket for use in receiving a packet of the given length starting at the specified offset into the buffer.

Parameters
bytesThe array of bytes to hold the incoming datagram buffer.
sizeThe size of the supplied byte array.
offsetThe position in the array to start writing to.
lengthThe number of byte to read starting at the supplied offset.
Exceptions
NullPointerExceptionif the pointer to the buffer is NULL.
IndexOutOfBoundsExceptionif the number of bytes to copy exceeds the buffer size.
decaf::net::DatagramPacket::DatagramPacket ( unsigned char *  bytes,
int  size,
int  offset,
int  length,
const InetAddress address,
int  port 
)

Creates a new DatagramPacket for use in sending a packet of the given length starting at the specified offset into the buffer to the specified host on the specified port.

Parameters
bytesThe array of bytes to hold the outgoing datagram buffer.
sizeThe size of the supplied byte array.
offsetThe position in the array to start writing to.
lengthThe number of byte to read starting at the supplied offset.
addressThe Address to send the packet to
portThe port on the destination that is to receive this packet.
Exceptions
NullPointerExceptionif the pointer to the buffer is NULL.
IndexOutOfBoundsExceptionif the number of bytes to copy exceeds the buffer size.
decaf::net::DatagramPacket::DatagramPacket ( unsigned char *  bytes,
int  size,
int  length,
const InetAddress address,
int  port 
)

Creates a new DatagramPacket for use in sending a packet of the given length to the specified host on the specified port.

Parameters
bytesThe array of bytes to hold the outgoing datagram buffer.
sizeThe size of the supplied byte array.
lengthThe number of byte to read starting at the supplied offset.
addressThe Address to send the packet to
portThe port on the destination that is to receive this packet.
Exceptions
NullPointerExceptionif the pointer to the buffer is NULL.
IndexOutOfBoundsExceptionif the number of bytes to copy exceeds the buffer size.
decaf::net::DatagramPacket::DatagramPacket ( unsigned char *  bytes,
int  size,
int  length,
const SocketAddress address 
)

Creates a new DatagramPacket for use in sending a packet of the given length into the buffer to the specified socket address.

Parameters
bytesThe array of bytes to hold the outgoing datagram buffer.
sizeThe size of the supplied byte array.
lengthThe number of byte to read starting at the supplied offset.
addressThe Address to send the packet to
Exceptions
NullPointerExceptionif the pointer to the buffer is NULL.
IndexOutOfBoundsExceptionif the number of bytes to copy exceeds the buffer size.
decaf::net::DatagramPacket::DatagramPacket ( unsigned char *  bytes,
int  size,
int  offset,
int  length,
const SocketAddress address 
)

Creates a new DatagramPacket for use in sending a packet of the given length starting at the specified offset into the buffer to the specified socket address.

Parameters
bytesThe array of bytes to hold the outgoing datagram buffer.
sizeThe size of the supplied byte array.
offsetThe position in the array to start writing to.
lengthThe number of byte to read starting at the supplied offset.
addressThe Address to send the packet to
Exceptions
NullPointerExceptionif the pointer to the buffer is NULL.
IndexOutOfBoundsExceptionif the number of bytes to copy exceeds the buffer size.
virtual decaf::net::DatagramPacket::~DatagramPacket ( )
virtual

Member Function Documentation

InetAddress* decaf::net::DatagramPacket::getAddress ( ) const
Returns
the IP address that this datagram packet is being sent to or was received from.
unsigned char* decaf::net::DatagramPacket::getData ( ) const
Returns
the data buffer. The data received or the data to be sent starts from the offset in the buffer, and continues for length bytes.
int decaf::net::DatagramPacket::getLength ( ) const
Returns
the length of the data to be sent or the length of the data received.
int decaf::net::DatagramPacket::getOffset ( ) const
Returns
the offset of the data to be sent or the offset of the data received.
int decaf::net::DatagramPacket::getPort ( ) const
Returns
the port number that this datagram packet is being sent to or was received from.
int decaf::net::DatagramPacket::getSize ( ) const
Returns
the size of the buffer used in this datagram packet.
SocketAddress* decaf::net::DatagramPacket::getSocketAddress ( ) const

Gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.

Returns
the SocketAddress for this datagram packet.
void decaf::net::DatagramPacket::setAddress ( const InetAddress address)

Sets the IP address of the machine to which this datagram is being sent.

Parameters
addressThe IP address.
void decaf::net::DatagramPacket::setData ( unsigned char *  buffer,
int  size 
)

Set the data buffer for this packet.

With the offset of this DatagramPacket set to 0, and the length set to the size value specified.

Parameters
bufferThe new data buffer to use for this datagram packet.
sizeThe size of the buffer.
Exceptions
NullPointerExceptionif the buffer pointer is NULL.
void decaf::net::DatagramPacket::setData ( unsigned char *  buffer,
int  size,
int  offset,
int  length 
)

Set the data buffer for this packet.

With the offset of this DatagramPacket set to 0, and the length set to the size value specified.

Parameters
bufferThe new data buffer to use for this datagram packet.
sizeThe size of the buffer.
offsetThe position in the buffer to read from or write to.
lengthThe number of bytes that will be read into the buffer or sent from the buffer.
Exceptions
NullPointerExceptionif the buffer pointer is NULL.
void decaf::net::DatagramPacket::setLength ( int  length)

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.

Parameters
lengthThe length value to set for this packet.
Exceptions
IllegalArgumentExceptionif the value is negative or exceeds the data buffers length.
void decaf::net::DatagramPacket::setOffset ( int  offset)

Sets the offset into the data buffer where data to sent is to be read from or where the data that is received should start writing to.

Parameters
offsetThe buffer offset value.
Exceptions
IllegalArgumentExceptionif the offset value is greater than the buffer size.
void decaf::net::DatagramPacket::setPort ( int  port)

Sets the port number on the remote host to which this datagram is being sent.

Parameters
portThe port on the remote host.
Exceptions
IllegalArgumentExceptionif the port value is not in the range [0..65535].
void decaf::net::DatagramPacket::setSocketAddress ( const SocketAddress address)

Sets the SocketAddress (usually IP address + port number) of the remote host to which this datagram is being sent.

Parameters
addressThe SocketAddress (IP + port) for this datagram packet.
Exceptions
IllegalArgumentExceptionif the subclass of address is not supported by this Socket.

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