From: jmo Date: Thu, 8 May 2008 07:07:46 +0000 (+0000) Subject: Server logs client address X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=489be2bbd4d03259a17df14e4962a4524cd5b654;p=senf.git Server logs client address git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@838 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Console/Server.cc b/Console/Server.cc index 9ab2c8d..ac9f034 100644 --- a/Console/Server.cc +++ b/Console/Server.cc @@ -27,7 +27,6 @@ #include "Server.ih" // Custom includes -#include #include #include #include @@ -248,6 +247,24 @@ prefix_ void senf::console::Client::v_write(boost::posix_time::ptime timestamp, reader_->enablePrompt(); } +prefix_ std::ostream & senf::console::operator<<(std::ostream & os, Client const & client) +{ + // typedef senf::ClientSocketHandle::policy > v4Socket; + if( senf::check_socket_cast( client.handle())) { + os<( client.handle()).peer(); + } + else if( senf::check_socket_cast( client.handle())) { + os<( client.handle()).peer(); + } + else{ + os<<((void *)&client); + } + return os; +} +prefix_ std::ostream & senf::console::operator<<(std::ostream & os, Client * client) +{ + return os<<*client; +} ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ //#include "Server.mpp" diff --git a/Console/Server.hh b/Console/Server.hh index dc7630d..be3dd6c 100644 --- a/Console/Server.hh +++ b/Console/Server.hh @@ -164,6 +164,12 @@ namespace console { friend class detail::ClientReader; friend class detail::NonblockingSocketSink; }; + + /** \brief Output INet4Address instance as it's string representation + \related INet4Address + */ + std::ostream & operator<<(std::ostream & os, Client const & client); + std::ostream & operator<<(std::ostream & os, Client * client); }} diff --git a/Console/testServer.cc b/Console/testServer.cc index e8123e2..3ed6ba9 100644 --- a/Console/testServer.cc +++ b/Console/testServer.cc @@ -110,7 +110,7 @@ int main(int, char **) TestObject test; testDir - .add("testob", test.dir) + .add("extra", test.dir) .doc("Example of an instance directory"); senf::console::Server::start( senf::INet4SocketAddress(23232u) )