4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief TCPv4SocketHandle and TCPv6SocketHandle public header
31 \todo Implement possibly non-blocking connect and SO_ERROR in the
35 #ifndef HH_SENF_Socket_Protocols_INet_TCPSocketHandle_
36 #define HH_SENF_Socket_Protocols_INet_TCPSocketHandle_ 1
39 #include "INetSocketProtocol.hh"
40 #include "TCPSocketProtocol.hh"
41 #include "INetAddressing.hh"
42 #include <senf/Socket/Protocols/BSDSocketProtocol.hh>
43 #include <senf/Socket/FramingPolicy.hh>
44 #include <senf/Socket/CommunicationPolicy.hh>
45 #include <senf/Socket/ReadWritePolicy.hh>
46 #include <senf/Socket/ProtocolClientSocketHandle.hh>
47 #include <senf/Socket/ProtocolServerSocketHandle.hh>
49 //#include "TCPSocketHandle.mpp"
50 //-/////////////////////////////////////////////////////////////////////////////////////////////////
54 /// \addtogroup concrete_protocol_group
57 typedef MakeSocketPolicy<
58 INet4AddressingPolicy,
60 ConnectedCommunicationPolicy,
63 >::policy TCPv4Socket_Policy; ///< Socket Policy of the TCPv4 Protocol
65 /** \brief IPv4 TCP Socket Protocol
67 \par Socket Handle typedefs:
68 \ref TCPv4ClientSocketHandle (ProtocolClientSocketHandle), \ref TCPv4ServerSocketHandle
69 (ProtocolServerSocketHandle)
71 \par Policy Interface:
72 ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
73 ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer()
78 TCPv4SocketProtocol provides an internet protocol stream socket based on the TCP protocol
81 This class is utilized as the protocol class of the ProtocolClientSocketHandle and
82 ProtocolServerSocketHandle via the Socket Handle typedefs above.
84 \see TCPv6SocketProtocol
86 class TCPv4SocketProtocol
87 : public ConcreteSocketProtocol<TCPv4Socket_Policy,TCPv4SocketProtocol>,
88 public TCPSocketProtocol,
89 public BSDSocketProtocol,
90 public AddressableBSDSocketProtocol
93 //-////////////////////////////////////////////////////////////////////////
99 void init_client() const; ///< Create unconnected client socket
100 /**< \note This member is implicitly called from the
101 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
103 void init_client(INet4SocketAddress const & address) const;
104 ///< Create client socket and connect
105 /**< Creates a new client socket and connects to the given
108 \param[in] address remote address to connect to */
109 /**< \note This member is implicitly called from the
110 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
112 void init_server() const; ///< Create server socket
113 /**< \note This member is implicitly called from the
114 ProtocolServerSocketHandle::ProtocolServerSocketHandle()
116 void init_server(INet4SocketAddress const & address, unsigned backlog=1) const;
117 ///< Create server socket and listen
118 /**< Creates a new server socket, binds to \a address end
119 starts listening for new connections with a backlog of
120 \a backlog connections. It also enables reuseaddr().
122 \param[in] address address to listen on
123 \param[in] backlog size of the listen backlog */
124 /**< \note This member is implicitly called from the
125 ProtocolServerSocketHandle::ProtocolServerSocketHandle()
131 typedef ProtocolClientSocketHandle<TCPv4SocketProtocol> TCPv4ClientSocketHandle;
132 typedef ProtocolServerSocketHandle<TCPv4SocketProtocol> TCPv4ServerSocketHandle;
134 typedef MakeSocketPolicy<
136 INet6AddressingPolicy
137 >::policy TCPv6Socket_Policy;
139 /** \brief IPv6 TCP Socket Protocol
141 \par Socket Handle typedefs:
142 \ref TCPv6ClientSocketHandle (ProtocolClientSocketHandle), \ref TCPv6ServerSocketHandle
143 (ProtocolServerSocketHandle)
145 \par Policy Interface:
146 ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
147 ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer()
152 TCPv6SocketProtocol provides an internet protocol stream socket based on the TCP protocol
155 This class is utilized as the protocol class of the ProtocolClientSocketHandle and
156 ProtocolServerSocketHandle via the Socket Handle typedefs above.
158 \see TCPv4SocketProtocol
160 class TCPv6SocketProtocol
161 : public ConcreteSocketProtocol<TCPv6Socket_Policy,TCPv6SocketProtocol>,
162 public TCPSocketProtocol,
163 public BSDSocketProtocol,
164 public AddressableBSDSocketProtocol
167 //-////////////////////////////////////////////////////////////////////////
168 // internal interface
170 ///\name Constructors
173 void init_client() const; ///< Create unconnected client socket
174 /**< \note This member is implicitly called from the
175 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
177 void init_client(INet6SocketAddress const & address) const;
178 ///< Create client socket and connect
179 /**< Creates a new client socket and connects to the given
182 \param[in] address remote address to connect to */
183 /**< \note This member is implicitly called from the
184 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
186 void init_server() const; ///< Create server socket
187 /**< \note This member is implicitly called from the
188 ProtocolServerSocketHandle::ProtocolServerSocketHandle()
190 void init_server(INet6SocketAddress const & address, unsigned backlog=1) const;
191 ///< Create server socket and listen
192 /**< Creates a new server socket, binds to \a address end
193 starts listening for new connections with a backlog of
194 \a backlog connections. It also enables reuseaddr().
196 \param[in] address address to listen on
197 \param[in] backlog size of the listen backlog */
198 /**< \note This member is implicitly called from the
199 ProtocolServerSocketHandle::ProtocolServerSocketHandle()
205 typedef ProtocolClientSocketHandle<TCPv6SocketProtocol> TCPv6ClientSocketHandle;
206 typedef ProtocolServerSocketHandle<TCPv6SocketProtocol> TCPv6ServerSocketHandle;
212 //-/////////////////////////////////////////////////////////////////////////////////////////////////
213 //#include "TCPSocketHandle.cci"
214 //#include "TCPSocketHandle.ct"
215 //#include "TCPSocketHandle.cti"
222 // c-file-style: "senf"
223 // indent-tabs-mode: nil
224 // ispell-local-dictionary: "american"
225 // compile-command: "scons -u test"
226 // comment-column: 40