#include <ipv6_udpposet.h>
Public Types | |
typedef std::multimap< int, Address > | Destinations |
TODO Revisit and see if possible to add multicast support. | |
typedef ConexusPointer< UDPPoset > | pointer |
Class typedef to smart pointer. | |
Public Member Functions | |
CONEXUS_ENDPOINT_GENERIC_CREATE () | |
virtual | ~UDPPoset () throw () |
Destructor. | |
virtual void | bind () throw ( bind_exception ) |
Bypasses parent UDP methods and goes straight to grandparent IP methods. | |
virtual void | bind (const Conexus::Address &a) throw ( bind_exception ) |
Bypasses parent UDP methods and goes straight to grandparent IP methods. | |
virtual void | close () throw ( close_exception ) |
Bypasses parent UDP methods and goes straight to grandparent IP methods. | |
virtual void | connect () throw ( connect_exception ) |
UDPPoset cannot connect; always throws exception::connect::no_udpposet_connect(). | |
virtual void | connect (const Address &a) throw ( connect_exception ) |
UDPPoset cannot connect; always throws exception::connect::no_udpposet_connect(). | |
virtual void | set_write_without_connect (bool value=true) |
Has no effect, write without connect must always be true. | |
bool | add_destination (const Address &destination, int priority=0, bool singleton=true) |
Add the destination with the given priority. | |
bool | add_destination (uint32_t host, uint16_t port, int priority=0, bool singleton=true) |
bool | add_destination (const struct in6_addr &host, uint16_t port, int priority=0, bool singleton=true) |
bool | add_destination (const std::string &host, uint16_t port, int priority=0, bool singleton=true) |
void | remove_destination (const Address &destination, int priority) |
Removes all instances of a destination for a specific priority level. | |
void | remove_destination (const Address &destination) |
Removes all instances of a destination for all priority levels. | |
bool | is_destination (const Address &destination) |
True if the address is a destination at any priority level. | |
bool | is_destination (const Address &destination, int priority) |
True if the address is a destination at the specified priority level. | |
std::set< int > | priorities (const Address &destination) |
Returns a set of the priority levels this destination is associated with or a vector of size zero if not present as a destination. | |
const Destinations & | destinations () |
Returns a constant reference to the map used to store destinations. | |
sigc::signal< void, Address, int > | signal_destination_added () |
Signal emitted when a destination is added. | |
sigc::signal< void, Address, int > | signal_destination_removed () |
Signal emitted when a destination is removed. | |
Static Public Member Functions | |
static UDPPoset::pointer | create (uint16_t localport=0) |
Returns a smart pointer to a new object. | |
static UDPPoset::pointer | create (const struct in6_addr &local_if, uint16_t localport=0) |
Returns a smart pointer to a new object. | |
static UDPPoset::pointer | create (const std::string &local_if, uint16_t localport=0) |
Returns a smart pointer to a new object. | |
Protected Member Functions | |
UDPPoset (const struct in6_addr &local_if, uint16_t localport=0) | |
Constructor. | |
UDPPoset (const std::string &local_if, uint16_t localport=0) | |
Constructor. | |
virtual void | on_local_address_changed () |
Do nothing when parent callback occurs. | |
virtual void | on_remote_address_changed () |
Do nothing when parent callback occurs. | |
virtual size_t | write_data (const Data data, Timeout timeout) throw (write_exception) |
Overloads the Socket ancestor send method to ensure that the socket is connected before trying to send. | |
Protected Attributes | |
Destinations | m_addresses |
Destination addresses. | |
sigc::signal< void, Address, int > | m_signal_destination_added |
Signal emitted when a destination is added. | |
sigc::signal< void, Address, int > | m_signal_destination_removed |
Signal emitted when a destination is removed. |
Although multicasting is generally a better solution, sometimes multicasting is not possible with certain frameworks; hence UDPPoset.
The advantage of UDPPoset over a vector of UDP sockets is that each instantiation of a UDP socket will use a local port. In contrast, the UDPPoset class will use a single port for all outgoing UDP traffic. Like the UDP class it inherits from, it is capable of receiving transmissions, but only for the single local port.
UDPPoset will only accept UDP unicast addresses; not multicast; not broadcast.
The name poset, or partially ordered set, was used since UDP destinations of equal priority have no guarantees on ordering. Priority is a numeric value, and transmissions will occur from the highest priority first to the lowest priority last.
typedef std::multimap<int,Address> Conexus::IPv6::UDPPoset::Destinations |
TODO Revisit and see if possible to add multicast support.
TODO examine adding socket pools Class typedef to destinations container
typedef ConexusPointer<UDPPoset> Conexus::IPv6::UDPPoset::pointer |
Class typedef to smart pointer.
Reimplemented from Conexus::IPv6::UDP.
Conexus::IPv6::UDPPoset::UDPPoset | ( | const struct in6_addr & | local_if, | |
uint16_t | localport = 0 | |||
) | [protected] |
Conexus::IPv6::UDPPoset::UDPPoset | ( | const std::string & | local_if, | |
uint16_t | localport = 0 | |||
) | [protected] |
Conexus::IPv6::UDPPoset::~UDPPoset | ( | ) | throw () [virtual] |
Destructor.
bool Conexus::IPv6::UDPPoset::add_destination | ( | const std::string & | host, | |
uint16_t | port, | |||
int | priority = 0 , |
|||
bool | singleton = true | |||
) |
References add_destination().
bool Conexus::IPv6::UDPPoset::add_destination | ( | const struct in6_addr & | host, | |
uint16_t | port, | |||
int | priority = 0 , |
|||
bool | singleton = true | |||
) |
References add_destination().
bool Conexus::IPv6::UDPPoset::add_destination | ( | uint32_t | host, | |
uint16_t | port, | |||
int | priority = 0 , |
|||
bool | singleton = true | |||
) |
References add_destination().
bool Conexus::IPv6::UDPPoset::add_destination | ( | const Address & | destination, | |
int | priority = 0 , |
|||
bool | singleton = true | |||
) |
Add the destination with the given priority.
destination | The destination address to add to the poset | |
priority | The priority level to add this destination to | |
singleton | If true, this will be the only priority level the destination will occur at, and there will only be a single occurrence at this priority level. |
What this means is that multiple transmissions will occur to the same destination. However, the use of the singleton parameter, which defaults to true, will ensure the uniqueness of a destination in the transmission set.
Examples:
UDPPoset my_udpposet; my_udpposet.add_destination( address1, 5 ); my_udpposet.add_destination( address1, 3 );
UDPPoset my_udpposet; my_udpposet.add_destination( address1, 5, false ); my_udpposet.add_destination( address1, 3, false );
UDPPoset my_udpposet; my_udpposet.add_destination( address1, 5, false ); my_udpposet.add_destination( address1, 5, false );
UDPPoset my_udpposet; my_udpposet.add_destination( address1, 5, false ); my_udpposet.add_destination( address1, 3, false ); my_udpposet.add_destination( address1, 1 );
UDPPoset my_udpposet; my_udpposet.add_destination( address1, 5, false ); my_udpposet.add_destination( address1, 3, false ); my_udpposet.add_destination( address1, 1 ); my_udpposet.add_destination( address1, 0, false );
References m_addresses, m_signal_destination_added, and remove_destination().
Referenced by add_destination().
void Conexus::IPv6::UDPPoset::bind | ( | const Conexus::Address & | a | ) | throw ( bind_exception ) [virtual] |
Bypasses parent UDP methods and goes straight to grandparent IP methods.
Reimplemented from Conexus::IPv6::UDP.
References Conexus::IPv6::IP::bind().
void Conexus::IPv6::UDPPoset::bind | ( | ) | throw ( bind_exception ) [virtual] |
Bypasses parent UDP methods and goes straight to grandparent IP methods.
Reimplemented from Conexus::IPv6::UDP.
void Conexus::IPv6::UDPPoset::close | ( | ) | throw ( close_exception ) [virtual] |
Bypasses parent UDP methods and goes straight to grandparent IP methods.
Reimplemented from Conexus::IPv6::UDP.
Conexus::IPv6::UDPPoset::CONEXUS_ENDPOINT_GENERIC_CREATE | ( | ) |
Reimplemented from Conexus::IPv6::UDP.
void Conexus::IPv6::UDPPoset::connect | ( | const Address & | a | ) | throw ( connect_exception ) [virtual] |
UDPPoset cannot connect; always throws exception::connect::no_udpposet_connect().
Since UDPPoset relies on sendto()
to perform transmission, it cannot connect since sendto()
ignores the to
parameter when connected.
Reimplemented from Conexus::IPv6::UDP.
void Conexus::IPv6::UDPPoset::connect | ( | ) | throw ( connect_exception ) [virtual] |
UDPPoset cannot connect; always throws exception::connect::no_udpposet_connect().
Since UDPPoset relies on sendto()
to perform transmission, it cannot connect since sendto()
ignores the to
parameter when connected.
Reimplemented from Conexus::IPv6::UDP.
UDPPoset::pointer Conexus::IPv6::UDPPoset::create | ( | const std::string & | local_if, | |
uint16_t | localport = 0 | |||
) | [static] |
UDPPoset::pointer Conexus::IPv6::UDPPoset::create | ( | const struct in6_addr & | local_if, | |
uint16_t | localport = 0 | |||
) | [static] |
UDPPoset::pointer Conexus::IPv6::UDPPoset::create | ( | uint16_t | localport = 0 |
) | [static] |
const UDPPoset::Destinations & Conexus::IPv6::UDPPoset::destinations | ( | ) |
bool Conexus::IPv6::UDPPoset::is_destination | ( | const Address & | destination, | |
int | priority | |||
) |
bool Conexus::IPv6::UDPPoset::is_destination | ( | const Address & | destination | ) |
void Conexus::IPv6::UDPPoset::on_local_address_changed | ( | ) | [protected, virtual] |
Do nothing when parent callback occurs.
Reimplemented from Conexus::IPv6::UDP.
References Conexus::Endpoint::close_and_reopen(), and Conexus::Socket::is_bound().
void Conexus::IPv6::UDPPoset::on_remote_address_changed | ( | ) | [protected, virtual] |
std::set< int > Conexus::IPv6::UDPPoset::priorities | ( | const Address & | destination | ) |
Returns a set of the priority levels this destination is associated with or a vector of size zero if not present as a destination.
References m_addresses.
void Conexus::IPv6::UDPPoset::remove_destination | ( | const Address & | destination | ) |
Removes all instances of a destination for all priority levels.
References m_addresses, and m_signal_destination_removed.
void Conexus::IPv6::UDPPoset::remove_destination | ( | const Address & | destination, | |
int | priority | |||
) |
Removes all instances of a destination for a specific priority level.
References m_addresses, and m_signal_destination_removed.
Referenced by add_destination().
void Conexus::IPv6::UDPPoset::set_write_without_connect | ( | bool | value = true |
) | [virtual] |
sigc::signal< void, Address, int > Conexus::IPv6::UDPPoset::signal_destination_added | ( | ) |
sigc::signal< void, Address, int > Conexus::IPv6::UDPPoset::signal_destination_removed | ( | ) |
size_t Conexus::IPv6::UDPPoset::write_data | ( | const Data | data, | |
Timeout | timeout | |||
) | throw (write_exception) [protected, virtual] |
Overloads the Socket ancestor send method to ensure that the socket is connected before trying to send.
Reimplemented from Conexus::IPv6::UDP.
References Conexus::ENDPOINT_OPENED, and Conexus::Socket::writeto().
Destinations Conexus::IPv6::UDPPoset::m_addresses [protected] |
Destination addresses.
Referenced by add_destination(), destinations(), is_destination(), priorities(), and remove_destination().
sigc::signal<void,Address,int> Conexus::IPv6::UDPPoset::m_signal_destination_added [protected] |
Signal emitted when a destination is added.
Referenced by add_destination(), and signal_destination_added().
sigc::signal<void,Address,int> Conexus::IPv6::UDPPoset::m_signal_destination_removed [protected] |
Signal emitted when a destination is removed.
Referenced by remove_destination(), and signal_destination_removed().