Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Directories
  • File List
  • File Members

ClientSocketHandle.hh

Go to the documentation of this file.
00001 // $Id: ClientSocketHandle.hh 1756 2011-01-06 10:10:07Z tho $
00002 //
00003 // Copyright (C) 2006
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00027 #ifndef HH_SENF_Socket_ClientSocketHandle_
00028 #define HH_SENF_Socket_ClientSocketHandle_ 1
00029 
00030 // Custom includes
00031 #include <boost/call_traits.hpp>
00032 #include <boost/range.hpp>
00033 #include <boost/utility.hpp>
00034 #include <boost/type_traits.hpp>
00035 #include "SocketHandle.hh"
00036 
00037 //#include "ClientSocketHandle.mpp"
00038 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00039 
00040 namespace senf {
00041 
00043     //\{
00044 
00045     template <class SPolicy> class ServerSocketHandle;
00046 
00088     template <class SPolicy>
00089     class ClientSocketHandle
00090         : public SocketHandle<SPolicy>
00091     {
00092     public:
00093         //-////////////////////////////////////////////////////////////////////////
00094         // Types
00095 
00097         typedef typename SPolicy::AddressingPolicy::Address Address;
00099 
00104         typedef typename boost::call_traits<Address>::param_type AddressParam;
00106 
00109         typedef ServerSocketHandle<SPolicy> ServerHandle;
00110 
00111         //-////////////////////////////////////////////////////////////////////////
00113         //\{
00114 
00115         // default default constructor
00116         // default copy constructor
00117         // default copy assignment
00118         // default destructor
00119 
00120         // here to implement
00121         ClientSocketHandle();
00122 
00123         // conversion constructors
00124 #       ifndef DOXYGEN
00125         template <class OtherPolicy>
00126         ClientSocketHandle(ClientSocketHandle<OtherPolicy> other,
00127                            typename SocketHandle<SPolicy>::template IsCompatible<OtherPolicy>::type * = 0);
00128 #       else
00129         ClientSocketHandle(ClientSocketHandle<OtherPolicy> other);
00130 #       endif
00131 
00132 #       ifndef DOXYGEN
00133         template <class OtherPolicy>
00134         typename SocketHandle<SPolicy>::template IsCompatible<OtherPolicy>::type const &
00135         operator=(ClientSocketHandle<OtherPolicy> other);
00136 #       else
00137         template <class OtherPolicy>
00138         ClientSocketHandle<OtherPolicy> const & operator=(ClientSocketHandle<OtherPolicy> other);
00139 #       endif
00140 
00141         //\}
00142         //-////////////////////////////////////////////////////////////////////////
00143 
00144         //-////////////////////////////////////////////////////////////////////////
00146         //\{
00147 
00178         std::string  read         (unsigned limit=0);
00179         template <class ForwardWritableRange>
00180 #       ifndef DOXYGEN
00181         typename boost::range_iterator<ForwardWritableRange>::type
00182                      read         (ForwardWritableRange const & range,
00183                                    typename boost::disable_if< boost::is_convertible<ForwardWritableRange,unsigned> >::type * = 0);
00184 #       else
00185         typename boost::range_iterator<ForwardWritableRange>::type
00186                      read         (ForwardWritableRange const & range);
00188 
00199 #       endif
00200 #       ifndef DOXYGEN
00201         template <class ForwardWritableRange>
00202         typename boost::range_iterator<ForwardWritableRange>::type
00203                      read         (ForwardWritableRange & range,
00204                                    typename boost::disable_if< boost::is_convertible<ForwardWritableRange,unsigned> >::type * = 0);
00205 #       else
00206         template <class ForwardWritableRange>
00207         typename boost::range_iterator<ForwardWritableRange>::type
00208                      read         (ForwardWritableRange & range);
00210 
00213 #       endif
00214         template <class Sequence>
00215         void         read         (Sequence & container, unsigned limit);
00217 
00224         char *       read         (char * start, char * end);
00226 
00251         std::pair<std::string, Address>
00252                      readfrom     (unsigned limit=0);
00253         template <class ForwardWritableRange>
00254         typename boost::range_iterator<ForwardWritableRange const>::type
00255                      readfrom     (ForwardWritableRange const & range, Address & from);
00257 
00270         template <class ForwardWritableRange>
00271         typename boost::range_iterator<ForwardWritableRange>::type
00272                      readfrom     (ForwardWritableRange & range, Address & from);
00274 
00277         template <class Sequence>
00278         void         readfrom     (Sequence & container, Address & from, unsigned limit);
00280 
00289         char *       readfrom     (char * start, char * end, Address & from);
00291 
00322         template <class ForwardReadableRange>
00323         typename boost::range_const_iterator<ForwardReadableRange const>::type
00324                      write        (ForwardReadableRange const & range);
00325         char const * write        (char const * start, char const * end);
00327 
00351         template <class ForwardReadableRange>
00352         typename boost::range_const_iterator<ForwardReadableRange const>::type
00353                      writeto      (AddressParam addr, ForwardReadableRange const & range);
00354         char const * writeto      (AddressParam addr, char const * start, char const * end);
00356 
00363         //-////////////////////////////////////////////////////////////////////////
00365         //\{
00366 
00377         void         connect      (AddressParam addr) const;
00378 
00388         void         bind         (AddressParam addr) const;
00389 
00401         Address      peer         () const;
00402         void         peer         (Address & addr) const;
00404 
00416         Address      local        () const;
00417         void         local        (Address & addr) const;
00419 
00421         //\}
00422 
00423         static ClientSocketHandle cast_static(FileHandle handle);
00424         static ClientSocketHandle cast_dynamic(FileHandle handle);
00425 
00426         // we need to override both since SocketHandle is *not* polymorphic
00427         void state(SocketStateMap & map, unsigned lod=0);
00428         std::string dumpState(unsigned lod=0);
00429 
00430         unsigned available();
00431 
00432     protected:
00433         ClientSocketHandle(FileHandle other, bool isChecked);
00434         explicit ClientSocketHandle(std::auto_ptr<SocketBody> body);
00435 
00436     private:
00437         friend class senf::ServerSocketHandle<SPolicy>;
00438     };
00439 
00440     //\}
00441 }
00442 
00443 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00444 //#include "ClientSocketHandle.cci"
00445 #include "ClientSocketHandle.ct"
00446 #include "ClientSocketHandle.cti"
00447 #endif
00448 
00449 
00450 // Local Variables:
00451 // mode: c++
00452 // fill-column: 100
00453 // c-file-style: "senf"
00454 // indent-tabs-mode: nil
00455 // ispell-local-dictionary: "american"
00456 // compile-command: "scons -u test"
00457 // comment-column: 40
00458 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research