ipv4_udp.h

00001 /***************************************************************************
00002  *   Copyright (C) 2001 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation version 2.1.                *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU Lesser General Public      *
00015  *   License along with this library; if not, write to the                 *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA              *
00018  ***************************************************************************/
00019 #ifndef CONEXUS_IPV4UDP_H
00020 #define CONEXUS_IPV4UDP_H
00021 
00022 #include <conexus/ipv4_ip.h>
00023 
00040 namespace Conexus {
00041 
00042   namespace IPv4 {
00043 
00050     class UDP : public IP {
00051       public:
00052         typedef boost::shared_ptr<UDP> pointer;
00053 
00054         UDP( uint16_t localport = 0, uint16_t remoteport = 0 );
00055 
00056         static UDP::pointer create( uint16_t localport = 0, uint16_t remoteport = 0 );
00057 
00058         virtual ~UDP() throw();
00059 
00060         virtual void bind() throw ( bind_error );
00061 
00062         virtual void bind( Conexus::Address& a ) throw ( bind_error );
00063 
00064         virtual void close() throw ( close_error );
00065 
00070         virtual int pending_input_datagram_size();
00071 
00075         virtual int pending_output_datagram_size();
00076 
00081         virtual ssize_t write( const void* data, size_t size ) throw ( write_error );
00082 
00089         virtual Data read( size_t s = -1 ) throw ( read_error );
00090 
00091         virtual void connect() throw ( connect_error );
00092         
00093         virtual void connect( Address& a ) throw ( connect_error ) {
00094           Socket::connect( a );
00095         }
00096 
00114         virtual void set_write_without_connect( bool value = true );
00115 
00116 
00117         virtual bool write_without_connect() const;
00118 
00119         virtual bool multicast_auto_join() const;
00120 
00121         virtual void set_multicast_auto_join( bool value = true );
00122 
00126         virtual int multicast_hops();
00127 
00131         virtual void set_multicast_hops( int hops );
00132 
00136         virtual bool multicast_loop();
00137 
00141         virtual void set_multicast_loop( bool loop );
00142 
00143         virtual const std::string& object_type() {
00144           static std::string s( "Conexus::IPv4::UDP" );
00145           return s;
00146         }
00147 
00148       protected:
00149         bool m_write_without_connect;
00150         bool m_multicast_auto_join;
00151         struct ip_mreq* m_multicast_request;
00152 
00153 
00155         virtual void join();
00156 
00158         virtual void leave();
00159 
00160         virtual void on_local_interface_changed( unsigned which );
00161         virtual void on_remote_address_changed( unsigned which );
00162     };
00163 
00164   }
00165 
00166 }
00167 
00168 #endif

Generated on Sat Aug 26 17:34:53 2006 by  doxygen 1.4.6