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;
45 template <class Policy>
46 class ServerSocketHandle
47 : public SocketHandle<Policy>
50 ///////////////////////////////////////////////////////////////////////////
53 typedef typename Policy::AddressingPolicy::Address Address;
54 typedef typename boost::call_traits<Address>::param_type AddressParam;
55 typedef ClientSocketHandle<Policy> ClientSocketHandle;
57 ///////////////////////////////////////////////////////////////////////////
58 ///\name Structors and default members
61 // no default constructor
62 // default copy constructor
63 // default copy assignment
66 // conversion constructors
67 template <class OtherPolicy>
68 ServerSocketHandle(ServerSocketHandle<OtherPolicy> other,
69 typename SocketHandle<Policy>::template IsCompatible<OtherPolicy>::type * = 0);
71 template <class OtherPolicy>
72 typename SocketHandle<Policy>::template IsCompatible<OtherPolicy>::type const &
73 operator=(ServerSocketHandle<OtherPolicy> other);
76 ///////////////////////////////////////////////////////////////////////////
78 ///////////////////////////////////////////////////////////////////////////
79 ///\name Server socket interface
82 void bind (AddressParam addr);
83 void listen (unsigned backlog=0);
86 void local (Address & addr);
88 // If the handle is non-blocking, accept will NOT block. If no connection
89 // is available to be returned, accept will return a ClientSocketHandle
90 // which is not valid()
93 std::pair<ClientSocketHandle, Address>
96 acceptfrom (Address & addr);
100 static ServerSocketHandle cast_static(FileHandle handle);
101 static ServerSocketHandle cast_dynamic(FileHandle handle);
103 // we need to override both since SocketHandle is *not* polymorphic
104 void state(SocketStateMap & map, unsigned lod=0);
105 std::string dumpState(unsigned lod=0);
108 ServerSocketHandle(FileHandle other, bool isChecked);
109 explicit ServerSocketHandle(std::auto_ptr<SocketProtocol> protocol);
118 ///////////////////////////////hh.e////////////////////////////////////////
119 //#include "ServerSocketHandle.cci"
120 //#include "ServerSocketHandle.ct"
121 #include "ServerSocketHandle.cti"
127 // c-file-style: "senf"