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////////////////////////////////////////
39 template <class Policy> class ClientSocketHandle;
43 template <class Policy>
44 class ServerSocketHandle
45 : public SocketHandle<Policy>
48 ///////////////////////////////////////////////////////////////////////////
51 typedef typename Policy::AddressingPolicy::Address Address;
52 typedef typename boost::call_traits<Address>::param_type AddressParam;
53 typedef ClientSocketHandle<Policy> ClientSocketHandle;
55 ///////////////////////////////////////////////////////////////////////////
56 ///\name Structors and default members
59 // no default constructor
60 // default copy constructor
61 // default copy assignment
64 // conversion constructors
65 template <class OtherPolicy>
66 ServerSocketHandle(ServerSocketHandle<OtherPolicy> other,
67 typename SocketHandle<Policy>::template IsCompatible<OtherPolicy>::type * = 0);
69 template <class OtherPolicy>
70 typename SocketHandle<Policy>::template IsCompatible<OtherPolicy>::type const &
71 operator=(ServerSocketHandle<OtherPolicy> other);
74 ///////////////////////////////////////////////////////////////////////////
76 ///////////////////////////////////////////////////////////////////////////
77 ///\name Server socket interface
80 void bind (AddressParam addr);
81 void listen (unsigned backlog=0);
84 void local (Address & addr);
86 // If the handle is non-blocking, accept will NOT block. If no connection
87 // is available to be returned, accept will return a ClientSocketHandle
88 // which is not valid()
91 std::pair<ClientSocketHandle, Address>
94 acceptfrom (Address & addr);
98 static ServerSocketHandle cast_static(FileHandle handle);
99 static ServerSocketHandle cast_dynamic(FileHandle handle);
101 // we need to override both since SocketHandle is *not* polymorphic
102 void state(SocketStateMap & map, unsigned lod=0);
103 std::string dumpState(unsigned lod=0);
106 ServerSocketHandle(FileHandle other, bool isChecked);
107 explicit ServerSocketHandle(std::auto_ptr<SocketProtocol> protocol);
115 ///////////////////////////////hh.e////////////////////////////////////////
116 //#include "ServerSocketHandle.cci"
117 //#include "ServerSocketHandle.ct"
118 #include "ServerSocketHandle.cti"
124 // c-file-style: "satcom"