X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FSocketProtocol.cc;h=4c78a9f68b4fabe4d844acd0c777234a707f289a;hb=6f50bf49e282c0528f51faa0a245bbfa2b867399;hp=d2c377f588583225c1d0ee37025ac056b5bdab2e;hpb=85ab07d100a382467a42e19d741d403a7a96c951;p=senf.git diff --git a/Socket/SocketProtocol.cc b/Socket/SocketProtocol.cc index d2c377f..4c78a9f 100644 --- a/Socket/SocketProtocol.cc +++ b/Socket/SocketProtocol.cc @@ -1,9 +1,9 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -24,6 +24,7 @@ \brief SocketProtocol and ConcreteSocketProtocol non-inline non-template implementation */ +#include #include "SocketProtocol.hh" //#include "SocketProtocol.ih" @@ -32,6 +33,29 @@ //#include "SocketProtocol.mpp" #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// +prefix_ void senf::SocketProtocol::close() + const +{ + if (::shutdown(body().fd(),SHUT_RDWR) < 0) + throwErrno(); + if (::close(body().fd()) < 0) + throwErrno(); +} + +prefix_ void senf::SocketProtocol::terminate() + const +{ + struct linger ling; + ling.l_onoff = 0; + ling.l_linger = 0; + + // We purposely IGNORE any errors: this method is used to try and + // terminate the connection ignoring any possible problems + + ::setsockopt(body().fd(),SOL_SOCKET,SO_LINGER,&ling,sizeof(ling)); + ::shutdown(body().fd(),SHUT_RDWR); + ::close(body().fd()); +} prefix_ void senf::SocketProtocol::state(SocketStateMap & map, unsigned lod) const @@ -48,4 +72,6 @@ prefix_ void senf::SocketProtocol::state(SocketStateMap & map, unsigned lod) // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 // End: