#include <datagram.h>

Public Member Functions | |
| datagram_message (size_t alloc_size) | |
| Create a messsage with no address, but with a buffer allocated to contain data. | |
| datagram_message (size_t alloc_size, const text &ip, int port) | |
| Create a messsage with address, and a buffer allocated to contain data. | |
| datagram_message (const void *data, size_t size, const text &ip, int port) | |
| Create a messsage with address, and a buffer allocated and initialised. | |
| virtual datagram_message * | clone (size_t alloc_size=0) const =0 |
| Create a copy of the message. | |
| virtual datagram_message * | clone (int port, size_t alloc_size=0) const =0 |
| Create a copy of the message, but change its port number. | |
| void | init (const text &ip, int port) |
| This method is called by the constructors to initialise the message. | |
| size_t | getSize () const |
| get the size of data actually written into the buffer | |
| uint8_t * | getDataPtr () |
| get a direct pointer to the actual data | |
Protected Attributes | |
| size_t | addrlen |
| The length of the address structure (this is dependant on the type of address). | |
| struct sockaddr * | addr |
| The address structure. | |
| size_t | size |
| The size of the data in the allocated data. | |
| size_t | alloc_size |
| The allocated size of the date. | |
| uint8_t * | data |
| The data buffer. | |
Friends | |
| class | datagram_server |
| class | datagram_client |
It contains all the information about the message: its size, data, and address.
| karoo::datagram_message::datagram_message | ( | size_t | alloc_size, | |
| const text & | ip, | |||
| int | port | |||
| ) |
Create a messsage with address, and a buffer allocated to contain data.
| alloc_size | the size of the buffer to allocate for data | |
| ip | the IP address (this can be an empty string to mean localhost, or it can be a host name, or in nnn.nnn.nnn.nnn format) | |
| port | the port to send to |
| bad_address | exception if there was a problem with the address |
| karoo::datagram_message::datagram_message | ( | const void * | data, | |
| size_t | size, | |||
| const text & | ip, | |||
| int | port | |||
| ) |
Create a messsage with address, and a buffer allocated and initialised.
| data | the data to initialise with | |
| size | the amount of data to initialise | |
| ip | the IP address (this can be an empty string to mean localhost, or it can be a host name, or in nnn.nnn.nnn.nnn format) | |
| port | the port to send to |
| bad_address | exception if there was a problem with the address |
| virtual datagram_message* karoo::datagram_message::clone | ( | int | port, | |
| size_t | alloc_size = 0 | |||
| ) | const [pure virtual] |
Create a copy of the message, but change its port number.
This is usually used to create a message already addressed to reply to an incoming message.
| alloc_size | if this is zero, then the new allocated size will be identical to this one's allocated size, otherwise, it will use the new value). Note that this clone must copy the old address across, but it creates a data buffer that is initialised to contain nothing. By "containing nothing", this means that the data buffer is allocated, but the size value is zero. In other words, the amount of valid data in the buffer is none. |
Implemented in karoo::rock_datagram_message.
| virtual datagram_message* karoo::datagram_message::clone | ( | size_t | alloc_size = 0 |
) | const [pure virtual] |
Create a copy of the message.
| alloc_size | if this is zero, then the new allocated size will be identical to this one's allocated size, otherwise, it will use the new value). Note that this clone must copy the old address across, but it creates a data buffer that is initialised to contain nothing. By "containing nothing", this means that the data buffer is allocated, but the size value is zero. In other words, the amount of valid data in the buffer is none. |
Implemented in karoo::rock_datagram_message.
size_t karoo::datagram_message::addrlen [protected] |
The length of the address structure (this is dependant on the type of address).
size_t karoo::datagram_message::alloc_size [protected] |
The allocated size of the date.
uint8_t* karoo::datagram_message::data [protected] |
size_t karoo::datagram_message::size [protected] |
The size of the data in the allocated data.
(This may be less than the allocated buffer).
Referenced by getSize().
1.5.8