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.
24 \brief ServerSocketHandle inline template implementation
27 // Definition of inline template functions
29 //#include "ServerSocketHandle.ih"
34 #define prefix_ inline
35 ///////////////////////////////cti.p///////////////////////////////////////
37 template <class Policy>
38 prefix_ senf::ServerSocketHandle<Policy>::ServerSocketHandle()
41 template <class SocketPolicy>
42 template <class OtherPolicy>
43 prefix_ senf::ServerSocketHandle<SocketPolicy>::
44 ServerSocketHandle(ServerSocketHandle<OtherPolicy> other,
45 typename SocketHandle<SocketPolicy>::template IsCompatible<OtherPolicy>::type *)
46 : SocketHandle<SocketPolicy>(other,true)
49 template <class SocketPolicy>
50 prefix_ senf::ServerSocketHandle<SocketPolicy>::
51 ServerSocketHandle(std::auto_ptr<SocketProtocol> protocol)
52 : SocketHandle<SocketPolicy>(protocol,true)
55 template <class SocketPolicy>
56 template <class OtherPolicy>
57 prefix_ typename senf::SocketHandle<SocketPolicy>::template IsCompatible<OtherPolicy>::type const &
58 senf::ServerSocketHandle<SocketPolicy>::operator=(ServerSocketHandle<OtherPolicy> other)
64 ///////////////////////////////////////////////////////////////////////////
65 // Server socket interface
67 template <class Policy>
68 prefix_ void senf::ServerSocketHandle<Policy>::bind(AddressParam addr)
70 Policy::AddressingPolicy::bind(*this,addr);
73 template <class Policy>
74 prefix_ void senf::ServerSocketHandle<Policy>::listen(unsigned backlog)
76 Policy::CommunicationPolicy::listen(*this,backlog);
79 template <class Policy>
80 prefix_ typename senf::ServerSocketHandle<Policy>::Address
81 senf::ServerSocketHandle<Policy>::local()
83 typename Policy::AddressingPolicy::Address addr;
88 template <class Policy>
89 prefix_ void senf::ServerSocketHandle<Policy>::local(Address & addr)
91 Policy::AddressingPolicy::local(*this,addr);
94 template <class Policy>
95 prefix_ typename senf::ServerSocketHandle<Policy>::ClientSocketHandle
96 senf::ServerSocketHandle<Policy>::accept()
99 return acceptfrom(address);
102 template <class Policy>
103 prefix_ std::pair<typename senf::ServerSocketHandle<Policy>::ClientSocketHandle,
104 typename senf::ServerSocketHandle<Policy>::Address>
105 senf::ServerSocketHandle<Policy>::acceptfrom()
109 ClientSocketHandle handle = accept(address);
110 return std::make_pair(handle,address);
113 template <class Policy>
114 prefix_ typename senf::ServerSocketHandle<Policy>::ClientSocketHandle
115 senf::ServerSocketHandle<Policy>::acceptfrom(Address & addr)
117 return ClientSocketHandle(this->protocol().clone(),
118 Policy::CommunicationPolicy::accept(*this,addr));
121 ///////////////////////////////////////////////////////////////////////////
123 template <class Policy>
124 prefix_ senf::ServerSocketHandle<Policy>::ServerSocketHandle(FileHandle other,
126 : SocketHandle<Policy>(other, isChecked)
129 template <class Policy>
130 prefix_ senf::ServerSocketHandle<Policy>
131 senf::ServerSocketHandle<Policy>::cast_static(FileHandle handle)
133 return ServerSocketHandle(handle,true);
136 template <class Policy>
137 prefix_ senf::ServerSocketHandle<Policy>
138 senf::ServerSocketHandle<Policy>::cast_dynamic(FileHandle handle)
140 SocketHandle<Policy> h (SocketHandle<Policy>::cast_dynamic(handle));
141 if (! static_cast<SocketBody&>(FileHandle::body(handle)).isServer())
142 throw std::bad_cast();
143 return cast_static(handle);
146 template <class Policy>
147 prefix_ void senf::ServerSocketHandle<Policy>::state(SocketStateMap & map, unsigned lod)
149 map["handle"] = prettyName(typeid(*this));
150 this->body().state(map,lod);
153 template <class Policy>
154 prefix_ std::string senf::ServerSocketHandle<Policy>::dumpState(unsigned lod)
158 return detail::dumpState(map);
161 ///////////////////////////////cti.e///////////////////////////////////////
168 // c-file-style: "senf"
169 // indent-tabs-mode: nil
170 // ispell-local-dictionary: "american"