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 
00028 namespace Conexus
00029   {
00030 
00031   namespace IPv4
00032     {
00033 
00040     class UDP : public IP
00041       {
00042       public:
00043         typedef boost::shared_ptr<UDP> pointer;
00044       
00045         UDP(uint16_t localport=0, uint16_t remoteport=0);
00046         
00047         static UDP::pointer create(uint16_t localport=0, uint16_t remoteport=0);
00048 
00049         virtual ~UDP() throw();
00050 
00051         virtual void bind() throw (bind_error);
00052 
00053         virtual void bind(Conexus::Address& a) throw (bind_error);
00054 
00055         virtual void close() throw (close_error);
00056 
00061         int pending_input_datagram_size();
00062 
00066         int pending_output_datagram_size();
00067 
00072         virtual ssize_t write(const void* data, size_t size) throw (write_error);
00073 
00080         virtual Data read(size_t s = -1)  throw (read_error);
00081 
00082         virtual void connect() throw (connect_error);
00083         virtual void connect(Address& a) throw (connect_error)
00084         {
00085           Socket::connect(a);
00086         }
00087 
00105         void set_write_without_connect(bool value=true);
00106 
00107 
00108         bool write_without_connect() const;
00109 
00110         bool multicast_auto_join() const;
00111 
00112         void set_multicast_auto_join(bool value=true);
00113 
00117         int multicast_hops();
00118 
00122         void set_multicast_hops(int hops);
00123 
00127         bool multicast_loop();
00128 
00132         void set_multicast_loop(bool loop);
00133 
00134         virtual const std::string& object_type() { static std::string s("Conexus::IPv4::UDP"); return s; }
00135 
00136         protected:
00137         bool m_write_without_connect;
00138         bool m_multicast_auto_join;
00139         struct ip_mreq* m_multicast_request;
00140 
00141 
00149         void join();
00150 
00158         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 Sun Aug 6 12:16:57 2006 by  doxygen 1.4.6