conexus logo

ipv4_udpposet.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2001 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This file is part of the conexus library.                             *
00006  *                                                                         *
00007  *   The conexus library is free software; you can redistribute it and/or  *
00008  *   modify it under the terms of the GNU General Public License           *
00009  *   version 3 as published by the Free Software Foundation.               *
00010  *                                                                         *
00011  *   The conexus library is distributed in the hope that it will be        *
00012  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty   *
00013  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
00014  *   General Public License for more details.                              *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU General Public License     *
00017  *   along with this software. If not see <http://www.gnu.org/licenses/>.  *
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 
00037 namespace Conexus
00038 {
00039 
00040   namespace IPv4
00041   {
00042 
00064     class UDPPoset : public UDP
00065     {
00066       protected:
00067 
00069         UDPPoset( uint32_t local_if, uint16_t localport );
00070 
00071         UDPPoset( const std::string& local_if, uint16_t localport );
00072 
00073       public:
00074         // TODO Revisit and see if possible to add multicast support
00075         // TODO examine adding socket pools
00076 
00078         typedef std::multimap<int,Address> Destinations;
00079 
00081         typedef ConexusPointer<UDPPoset> pointer;
00082 
00083         CONEXUS_ENDPOINT_GENERIC_CREATE();
00084 
00086         static UDPPoset::pointer create( uint16_t localport = 0 );
00087 
00089         static UDPPoset::pointer create( uint32_t local_if, uint16_t localport = 0 );
00090 
00092         static UDPPoset::pointer create( const std::string& local_if, uint16_t localport = 0 );
00093 
00095         virtual ~UDPPoset() throw();
00096 
00098         virtual void bind() throw ( bind_exception );
00099 
00101         virtual void bind( const Conexus::Address& a ) throw ( bind_exception );
00102 
00104         virtual void close() throw ( close_exception );
00105 
00112         virtual void connect() throw ( connect_exception );
00113 
00120         virtual void connect( const Address& a ) throw ( connect_exception );
00121 
00123         virtual void set_write_without_connect( bool value = true );
00124 
00182         bool add_destination( const Address& destination, int priority = 0, bool singleton = true );
00183 
00184         bool add_destination( uint32_t host, uint16_t port, int priority = 0, bool singleton = true );
00185 
00186         bool add_destination( std::string host, uint16_t port, int priority = 0, bool singleton = true );
00187 
00189         void remove_destination( const Address& destination, int priority );
00190 
00192         void remove_destination( const Address& destination );
00193 
00195         bool is_destination( const Address& destination );
00196 
00198         bool is_destination( const Address& destination, int priority );
00199 
00204         std::set<int> priorities( const Address& destination );
00205 
00207         const Destinations& destinations();
00208 
00210         sigc::signal<void,Address,int> signal_destination_added();
00211 
00213         sigc::signal<void,Address,int> signal_destination_removed();
00214 
00215       protected:
00217         Destinations m_addresses;
00218 
00220         sigc::signal<void,Address,int> m_signal_destination_added;
00221 
00223         sigc::signal<void,Address,int> m_signal_destination_removed;
00224 
00226         virtual void on_local_address_changed( unsigned which );
00227 
00229         virtual void on_remote_address_changed( unsigned which );
00230 
00235         virtual size_t write_data(const Data data, Timeout timeout) throw (write_exception);
00236 
00237     };
00238 
00239   }
00240 
00241 }
00242 
00243 #endif

Generated on Wed Jul 8 15:50:07 2009 for conexus by doxygen 1.5.8