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

SocketHandle.cc

Go to the documentation of this file.
00001 // $Id: SocketHandle.cc 1772 2011-03-10 12:45:21Z 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 #include "SocketHandle.hh"
00028 #include "SocketHandle.ih"
00029 
00030 // Custom includes
00031 #include <sstream>
00032 #include <senf/Utils/TypeInfo.hh>
00033 
00034 //#include "SocketHandle.mpp"
00035 #define prefix_
00036 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00037 
00038 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00039 // senf::SocketBody
00040 
00041 prefix_ void senf::SocketBody::state(SocketStateMap & map, unsigned lod)
00042 {
00043     map["file.handle"]     << fd();
00044     map["file.refcount"]   << refcount();
00045     map["socket.server"]   << isServer();
00046     map["socket.protocol"] << v_protocolName();
00047     map["socket.protocol.policy"] << prettyName(typeid(protocol().policy()));
00048     protocol().state(map,lod);
00049 }
00050 
00051 prefix_ void senf::SocketBody::v_close()
00052 {
00053     protocol().close();
00054 }
00055 
00056 prefix_ void senf::SocketBody::v_terminate()
00057 {
00058     protocol().terminate();
00059 }
00060 
00061 prefix_ bool senf::SocketBody::v_eof()
00062     const
00063 {
00064     return protocol().eof();
00065 }
00066 
00067 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00068 // senf::detail::StateMapOrdering
00069 
00070 namespace {
00071     bool contains(std::string::const_iterator b, std::string::const_iterator e, char c)
00072     {
00073         for (; b != e; ++b)
00074             if (*b == c)
00075                 return true;
00076         return false;
00077     }
00078 }
00079 
00080 prefix_ std::string senf::detail::dumpState(SocketStateMap const & map)
00081 {
00082     std::stringstream s;
00083     SocketStateMap::const_iterator i (map.begin());
00084     SocketStateMap::const_iterator i_end (map.end());
00085     for (; i != i_end; ++i)
00086         s << i->first << ": " << i->second << "\n";
00087     return s.str();
00088 }
00089 
00090 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00091 #undef prefix_
00092 //#include "SocketHandle.mpp"
00093 
00094 
00095 // Local Variables:
00096 // mode: c++
00097 // fill-column: 100
00098 // c-file-style: "senf"
00099 // indent-tabs-mode: nil
00100 // ispell-local-dictionary: "american"
00101 // compile-command: "scons -u test"
00102 // comment-column: 40
00103 // End:

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