SENF Extensible Network Framework
Home
Overview
Examples
HowTos
Glossary
Ext
NetEmu
PPI
Packets
Scheduler
Socket
Utils
Console
Daemon
Logger
Termlib
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
28
prefix_
void
senf::SocketProtocol::close
()
29
{
30
if
(::
close
(body().
fd
()) < 0)
31
SENF_THROW_SYSTEM_EXCEPTION
(
"::close(socket_fd)"
);
32
}
33
34
prefix_
void
senf::SocketProtocol::terminate
()
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:
SENF_THROW_SYSTEM_EXCEPTION
#define SENF_THROW_SYSTEM_EXCEPTION(desc)
senf::SocketProtocol::fd
int fd() const
Get file descriptor.
prefix_
#define prefix_
Definition:
SocketProtocol.cc:25
senf::SocketProtocol::state
virtual void state(SocketStateMap &map, unsigned lod) const
Return socket state information.
Definition:
SocketProtocol.cc:49
SocketProtocol.hh
SocketProtocol and ConcreteSocketProtocol public header.
senf::SocketProtocol::close
virtual void close()
Close socket.
Definition:
SocketProtocol.cc:28
senf::SocketProtocol::terminate
virtual void terminate() const
Forcibly close socket.
Definition:
SocketProtocol.cc:34