00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CONEXUS_IPV4UDPPOSET_H
00020 #define CONEXUS_IPV4UDPPOSET_H
00021
00022 #include <conexus/ipv4_udp.h>
00023
00024 #include <map>
00025 #include <set>
00026
00054 namespace Conexus
00055 {
00056
00057 namespace IPv4
00058 {
00059
00080 class UDPPoset : public UDP
00081 {
00082 protected:
00083
00085 UDPPoset( uint32_t local_if, uint16_t localport );
00086
00087 UDPPoset( const std::string& local_if, uint16_t localport );
00088
00089 public:
00094 typedef std::multimap<int,Address> Destinations;
00095
00097 typedef ConexusPointer<UDPPoset> pointer;
00098
00100 static UDPPoset::pointer create( uint16_t localport = 0 );
00101
00103 static UDPPoset::pointer create( uint32_t local_if, uint16_t localport = 0 );
00104
00106 static UDPPoset::pointer create( const std::string& local_if, uint16_t localport = 0 );
00107
00109 virtual ~UDPPoset() throw();
00110
00112 virtual void bind() throw ( bind_exception );
00113
00115 virtual void bind( const Conexus::Address& a ) throw ( bind_exception );
00116
00118 virtual void close() throw ( close_exception );
00119
00126 virtual void connect() throw ( connect_exception );
00127
00134 virtual void connect( const Address& a ) throw ( connect_exception );
00135
00137 virtual void set_write_without_connect( bool value = true );
00138
00196 bool add_destination( const Address& destination, int priority = 0, bool singleton = true );
00197
00198 bool add_destination( uint32_t host, uint16_t port, int priority = 0, bool singleton = true );
00199
00200 bool add_destination( std::string host, uint16_t port, int priority = 0, bool singleton = true );
00201
00203 void remove_destination( const Address& destination, int priority );
00204
00206 void remove_destination( const Address& destination );
00207
00209 bool is_destination( const Address& destination );
00210
00212 bool is_destination( const Address& destination, int priority );
00213
00218 std::set<int> priorities( const Address& destination );
00219
00221 const Destinations& destinations();
00222
00224 sigc::signal<void,Address,int> signal_destination_added();
00225
00227 sigc::signal<void,Address,int> signal_destination_removed();
00228
00229 protected:
00231 Destinations m_addresses;
00232
00234 sigc::signal<void,Address,int> m_signal_destination_added;
00235
00237 sigc::signal<void,Address,int> m_signal_destination_removed;
00238
00240 virtual void on_local_address_changed( unsigned which );
00241
00243 virtual void on_remote_address_changed( unsigned which );
00244
00249 virtual ssize_t write_data(long int timeout, const Data data) throw (write_exception);
00250
00251 };
00252
00253 }
00254
00255 }
00256
00257 #endif