00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00027 #include "SocketHandle.hh"
00028 #include "SocketHandle.ih"
00029
00030
00031 #include <sstream>
00032 #include <senf/Utils/TypeInfo.hh>
00033
00034
00035 #define prefix_
00036
00037
00038
00039
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
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
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103