SocketProtocol.cc
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
18 #include "SocketProtocol.hh"
19 //#include "SocketProtocol.ih"
20 
21 // Custom includes
22 #include <sys/socket.h>
23 
24 //#include "SocketProtocol.mpp"
25 #define prefix_
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 
29 {
30  if (::close(body().fd()) < 0)
31  SENF_THROW_SYSTEM_EXCEPTION("::close(socket_fd)");
32 }
33 
35  const
36 {
37  struct linger ling;
38  ling.l_onoff = 0;
39  ling.l_linger = 0;
40 
41  // We purposely IGNORE any errors: this method is used to try and
42  // terminate the connection ignoring any possible problems
43 
44  ::setsockopt(body().fd(),SOL_SOCKET,SO_LINGER,&ling,sizeof(ling));
45  ::shutdown(body().fd(),SHUT_RDWR);
46  ::close(body().fd());
47 }
48 
49 prefix_ void senf::SocketProtocol::state(SocketStateMap & map, unsigned lod)
50  const
51 {}
52 
53 //-/////////////////////////////////////////////////////////////////////////////////////////////////
54 #undef prefix_
55 //#include "SocketProtocol.mpp"
56 
57 
58 // Local Variables:
59 // mode: c++
60 // fill-column: 100
61 // c-file-style: "senf"
62 // indent-tabs-mode: nil
63 // ispell-local-dictionary: "american"
64 // compile-command: "scons -u test"
65 // comment-column: 40
66 // End:
#define SENF_THROW_SYSTEM_EXCEPTION(desc)
int fd() const
Get file descriptor.
#define prefix_
virtual void state(SocketStateMap &map, unsigned lod) const
Return socket state information.
SocketProtocol and ConcreteSocketProtocol public header.
virtual void close()
Close socket.
virtual void terminate() const
Forcibly close socket.