4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <stefan.bund@fokus.fraunhofer.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #ifndef HH_ServerSocketHandle_
24 #define HH_ServerSocketHandle_ 1
27 #include <boost/static_assert.hpp>
28 #include <boost/call_traits.hpp>
29 #include "SocketHandle.hh"
30 #include "CommunicationPolicy.hh"
31 #include "AddressingPolicy.hh"
33 //#include "ServerSocketHandle.mpp"
34 ///////////////////////////////hh.p////////////////////////////////////////
38 /// \addtogroup handle_group
41 template <class Policy> class ClientSocketHandle;
46 <tr><td>senf::ServerSocketHandle::bind</td> <td>AddressingPolicy::bind (\ref senf::AddressingPolicyBase)</td></tr>
47 <tr><td>senf::ServerSocketHandle::listen</td> <td>CommunicationPolicy::listen (\ref senf::CommunicationPolicyBase)</td></tr>
48 <tr><td>senf::ServerSocketHandle::local</td> <td>AddressingPolicy::local (\ref senf::AddressingPolicyBase)</td></tr>
49 <tr><td>senf::ServerSocketHandle::accept</td> <td>CommunicationPolicy::accept (\ref senf::CommunicationPolicyBase)</td></tr>
50 <tr><td>senf::ServerSocketHandle::acceptfrom</td> <td>CommunicationPolicy::accept (\ref senf::CommunicationPolicyBase)</td></tr>
54 template <class Policy>
55 class ServerSocketHandle
56 : public SocketHandle<Policy>
59 ///////////////////////////////////////////////////////////////////////////
62 typedef typename Policy::AddressingPolicy::Address Address;
63 typedef typename boost::call_traits<Address>::param_type AddressParam;
64 typedef ClientSocketHandle<Policy> ClientSocketHandle;
66 ///////////////////////////////////////////////////////////////////////////
67 ///\name Structors and default members
70 // no default constructor
71 // default copy constructor
72 // default copy assignment
75 // conversion constructors
76 template <class OtherPolicy>
77 ServerSocketHandle(ServerSocketHandle<OtherPolicy> other,
78 typename SocketHandle<Policy>::template IsCompatible<OtherPolicy>::type * = 0);
80 template <class OtherPolicy>
81 typename SocketHandle<Policy>::template IsCompatible<OtherPolicy>::type const &
82 operator=(ServerSocketHandle<OtherPolicy> other);
85 ///////////////////////////////////////////////////////////////////////////
87 ///////////////////////////////////////////////////////////////////////////
88 ///\name Server socket interface
91 void bind (AddressParam addr);
92 void listen (unsigned backlog=0);
95 void local (Address & addr);
97 // If the handle is non-blocking, accept will NOT block. If no connection
98 // is available to be returned, accept will return a ClientSocketHandle
99 // which is not valid()
102 std::pair<ClientSocketHandle, Address>
105 acceptfrom (Address & addr);
109 static ServerSocketHandle cast_static(FileHandle handle);
110 static ServerSocketHandle cast_dynamic(FileHandle handle);
112 // we need to override both since SocketHandle is *not* polymorphic
113 void state(SocketStateMap & map, unsigned lod=0);
114 std::string dumpState(unsigned lod=0);
117 ServerSocketHandle(FileHandle other, bool isChecked);
118 explicit ServerSocketHandle(std::auto_ptr<SocketProtocol> protocol);
127 ///////////////////////////////hh.e////////////////////////////////////////
128 //#include "ServerSocketHandle.cci"
129 //#include "ServerSocketHandle.ct"
130 #include "ServerSocketHandle.cti"
136 // c-file-style: "senf"