ServerSocketHandle.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_ServerSocketHandle_
19 #define HH_SENF_Socket_ServerSocketHandle_ 1
20 
21 // Custom includes
22 #include <boost/call_traits.hpp>
23 #include "SocketHandle.hh"
24 
25 //#include "ServerSocketHandle.mpp"
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 
28 namespace senf {
29 
31  //\{
32 
33  template <class SPolicy> class ClientSocketHandle;
34 
63  template <class SPolicy>
64  class ServerSocketHandle
65  : public SocketHandle<SPolicy>
66  {
67  public:
68  //-////////////////////////////////////////////////////////////////////////
69  // Types
70 
72  typedef typename SPolicy::AddressingPolicy::Address Address;
74 
79  typedef typename boost::call_traits<Address>::param_type AddressParam;
82 
83  //-////////////////////////////////////////////////////////////////////////
85  //\{
86 
87  // default default constructor
88  // default copy constructor
89  // default copy assignment
90  // default destructor
91 
92  // here to implement
94 
95  // conversion constructors
96  template <class OtherPolicy>
99 
100  template <class OtherPolicy>
103 
104  //\}
105  //-////////////////////////////////////////////////////////////////////////
106 
107  //-////////////////////////////////////////////////////////////////////////
109  //\{
110 
120  void bind (AddressParam addr);
121 
131  // Possible solution: Make listen() an abstract method of the protocol interface, make the
132  // backlog parameter into a member living in the body or protocol class and set it using
133  // some accessor. Hmm ... this all seems somehow futile ...
134  void listen (unsigned backlog=0);
135 
146  Address local ();
147  void local (Address & addr);
149 
162  ClientHandle accept ();
163  std::pair<ClientHandle, Address>
164  acceptfrom ();
165 
170  ClientHandle acceptfrom (Address & addr);
172 
178  //\}
179 
182 
183  // we need to override both since SocketHandle is *not* polymorphic
184  void state(SocketStateMap & map, unsigned lod=0);
185  std::string dumpState(unsigned lod=0);
186 
187  protected:
188  ServerSocketHandle(FileHandle other, bool isChecked);
189  explicit ServerSocketHandle(std::unique_ptr<SocketBody> body);
190 
191  private:
192 
193  };
194 
195  //\}
196 }
197 
198 //-/////////////////////////////////////////////////////////////////////////////////////////////////
199 //#include "ServerSocketHandle.cci"
200 //#include "ServerSocketHandle.ct"
201 #include "ServerSocketHandle.cti"
202 #endif
203 
204 
205 // Local Variables:
206 // mode: c++
207 // fill-column: 100
208 // c-file-style: "senf"
209 // indent-tabs-mode: nil
210 // ispell-local-dictionary: "american"
211 // compile-command: "scons -u test"
212 // comment-column: 40
213 // End:
std::string dumpState(unsigned lod=0)
static ServerSocketHandle cast_static(FileHandle handle)
std::pair< ClientHandle, Address > acceptfrom()
Accept new connection.
SPolicy::AddressingPolicy::Address Address
Address type from the addressing policy.
SocketHandle< SPolicy >::template IsCompatible< OtherPolicy >::type const & operator=(ServerSocketHandle< OtherPolicy > other)
Generic SocketHandle with client interface.
Generic SocketHandle with server interface.
void listen(unsigned backlog=0)
Allow clients to connect to this server socket.
Basic file handle wrapper.
Definition: FileHandle.hh:102
void bind(AddressParam addr)
Set local address.
ClientHandle accept()
Accept new connection.
ClientSocketHandle< SPolicy > ClientHandle
Corresponding client socket handle with the same policy.
basic SocketHandle supporting protocol and policy abstraction
Definition: SocketHandle.hh:60
Address local()
Query local address.
SocketBody & body()
Access socket body.
boost::call_traits< Address >::param_type AddressParam
&#39;Best&#39; type for passing address as parameter
static ServerSocketHandle cast_dynamic(FileHandle handle)
SocketHandle public header.
Check policy compatibility.
Definition: SocketHandle.hh:76
void state(SocketStateMap &map, unsigned lod=0)