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 // Definition of inline template functions
25 //#include "ServerSocketHandle.ih"
30 #define prefix_ inline
31 ///////////////////////////////cti.p///////////////////////////////////////
33 template <class SocketPolicy>
34 template <class OtherPolicy>
35 prefix_ satcom::lib::ServerSocketHandle<SocketPolicy>::
36 ServerSocketHandle(ServerSocketHandle<OtherPolicy> other,
37 typename SocketHandle<SocketPolicy>::template IsCompatible<OtherPolicy>::type *)
38 : SocketHandle<SocketPolicy>(other,true)
41 template <class SocketPolicy>
42 prefix_ satcom::lib::ServerSocketHandle<SocketPolicy>::
43 ServerSocketHandle(std::auto_ptr<SocketProtocol> protocol)
44 : SocketHandle<SocketPolicy>(protocol,true)
47 template <class SocketPolicy>
48 template <class OtherPolicy>
49 prefix_ typename satcom::lib::SocketHandle<SocketPolicy>::template IsCompatible<OtherPolicy>::type const &
50 satcom::lib::ServerSocketHandle<SocketPolicy>::operator=(ServerSocketHandle<OtherPolicy> other)
56 ///////////////////////////////////////////////////////////////////////////
57 // Server socket interface
59 template <class Policy>
60 prefix_ void satcom::lib::ServerSocketHandle<Policy>::bind(AddressParam addr)
62 Policy::AddressingPolicy::bind(*this,addr);
65 template <class Policy>
66 prefix_ void satcom::lib::ServerSocketHandle<Policy>::listen(unsigned backlog)
68 Policy::CommunicationPolicy::listen(*this,backlog);
71 template <class Policy>
72 prefix_ typename satcom::lib::ServerSocketHandle<Policy>::Address
73 satcom::lib::ServerSocketHandle<Policy>::local()
75 typename Policy::AddressingPolicy::Address addr;
80 template <class Policy>
81 prefix_ void satcom::lib::ServerSocketHandle<Policy>::local(Address & addr)
83 Policy::AddressingPolicy::local(*this,addr);
86 template <class Policy>
87 prefix_ typename satcom::lib::ServerSocketHandle<Policy>::ClientSocketHandle
88 satcom::lib::ServerSocketHandle<Policy>::accept()
91 return acceptfrom(address);
94 template <class Policy>
95 prefix_ std::pair<typename satcom::lib::ServerSocketHandle<Policy>::ClientSocketHandle,
96 typename satcom::lib::ServerSocketHandle<Policy>::Address>
97 satcom::lib::ServerSocketHandle<Policy>::acceptfrom()
101 ClientSocketHandle handle = accept(address);
102 return std::make_pair(handle,address);
105 template <class Policy>
106 prefix_ typename satcom::lib::ServerSocketHandle<Policy>::ClientSocketHandle
107 satcom::lib::ServerSocketHandle<Policy>::acceptfrom(Address & addr)
109 return ClientSocketHandle(this->protocol().clone(),
110 Policy::CommunicationPolicy::accept(*this,addr));
113 ///////////////////////////////////////////////////////////////////////////
115 template <class Policy>
116 prefix_ satcom::lib::ServerSocketHandle<Policy>::ServerSocketHandle(FileHandle other,
118 : SocketHandle<Policy>(other, isChecked)
121 template <class Policy>
122 prefix_ satcom::lib::ServerSocketHandle<Policy>
123 satcom::lib::ServerSocketHandle<Policy>::cast_static(FileHandle handle)
125 return ServerSocketHandle(handle,true);
128 template <class Policy>
129 prefix_ satcom::lib::ServerSocketHandle<Policy>
130 satcom::lib::ServerSocketHandle<Policy>::cast_dynamic(FileHandle handle)
132 SocketHandle<Policy> h (SocketHandle<Policy>::cast_dynamic(handle));
133 if (! static_cast<SocketBody&>(FileHandle::body(handle)).isServer())
134 throw std::bad_cast();
135 return cast_static(handle);
138 template <class Policy>
139 prefix_ void satcom::lib::ServerSocketHandle<Policy>::state(SocketStateMap & map, unsigned lod)
141 map["handle"] = prettyName(typeid(*this));
142 this->body().state(map,lod);
145 template <class Policy>
146 prefix_ std::string satcom::lib::ServerSocketHandle<Policy>::dumpState(unsigned lod)
150 return detail::dumpState(map);
153 ///////////////////////////////cti.e///////////////////////////////////////
159 // c-file-style: "satcom"