CommunicationPolicy.hh
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 #ifndef HH_SENF_Socket_CommunicationPolicy_
19 #define HH_SENF_Socket_CommunicationPolicy_ 1
20 
21 // Custom includes
22 #include "AddressingPolicy.hh"
23 #include "FileHandle.hh"
24 
25 //#include "CommunicationPolicy.mpp"
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 
28 struct sockaddr;
29 
30 namespace senf {
31 
33  //\{
34 
35  template <class SPolicy> class ServerSocketHandle;
36 
43  {
44 # ifndef DOXYGEN
45  template <class SPolicy>
46  static void listen(ServerSocketHandle<SPolicy> const & handle, unsigned backlog,
48 # else
49  template <class SPolicy>
50  static void listen(ServerSocketHandle<SPolicy> const & handle, unsigned backlog);
52 
54 # endif
55 
56 # ifndef DOXYGEN
57  template <class SPolicy>
58  static int accept(ServerSocketHandle<SPolicy> const & handle,
59  typename ServerSocketHandle<SPolicy>::Address & address,
61 # else
62  template <class SPolicy>
63  static int accept(ServerSocketHandle<SPolicy> const & handle,
64  typename ServerSocketHandle<SPolicy>::Address & address);
66 
75 # endif
76 
77  static int accept(FileHandle const & handle);
79 
87  private:
88  static void do_listen(FileHandle const & handle, unsigned backlog);
89  static int do_accept(FileHandle const & handle, struct sockaddr * addr, unsigned len);
90  };
91 
100  {};
101 
102  //\}
103 
104 }
105 
106 
107 //-/////////////////////////////////////////////////////////////////////////////////////////////////
108 #include "CommunicationPolicy.cci"
109 //#include "CommunicationPolicy.ct"
110 #include "CommunicationPolicy.cti"
111 #endif
112 
113 
114 // Local Variables:
115 // mode: c++
116 // fill-column: 100
117 // c-file-style: "senf"
118 // indent-tabs-mode: nil
119 // ispell-local-dictionary: "american"
120 // compile-command: "scons -u test"
121 // comment-column: 40
122 // End:
Inversion of IfAddressingPolicyIs.
static int accept(ServerSocketHandle< SPolicy > const &handle, typename ServerSocketHandle< SPolicy >::Address &address)
accept a new connection on the socket.
SPolicy::AddressingPolicy::Address Address
Address type from the addressing policy.
CommunicationPolicy for connected sockets.
Policy defining, how peers are selected.
Generic SocketHandle with server interface.
Basic file handle wrapper.
Definition: FileHandle.hh:102
static void listen(ServerSocketHandle< SPolicy > const &handle, unsigned backlog)
Enable establishing new connections on the socket.
CommunicationPolicy for unconnected sockets.
NoAddressingPolicy public header.
FileHandle public header.