4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.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 TCPv4SocketHandle and TCPv6SocketHandle public header
26 \todo Implement possibly non-blocking connect and SO_ERROR in the
30 #ifndef HH_TCPSocketHandle_
31 #define HH_TCPSocketHandle_ 1
34 #include "INetProtocol.hh"
35 #include "TCPProtocol.hh"
36 #include "../../../Socket/Protocols/BSDSocketProtocol.hh"
37 #include "../../../Socket/FramingPolicy.hh"
38 #include "../../../Socket/CommunicationPolicy.hh"
39 #include "../../../Socket/ReadWritePolicy.hh"
40 #include "../../../Socket/ProtocolClientSocketHandle.hh"
41 #include "../../../Socket/ProtocolServerSocketHandle.hh"
43 //#include "TCPSocketHandle.mpp"
44 ///////////////////////////////hh.p////////////////////////////////////////
48 /// \addtogroup concrete_protocol_group
51 typedef MakeSocketPolicy<
52 INet4AddressingPolicy,
54 ConnectedCommunicationPolicy,
57 >::policy TCPv4Socket_Policy; ///< Socket Policy of the TCPv4 Protocol
59 /** \brief IPv4 TCP Socket Protocol
61 \par Socket Handle typedefs:
62 \ref TCPv4ClientSocketHandle (ProtocolClientSocketHandle), \ref TCPv4ServerSocketHandle
63 (ProtocolServerSocketHandle)
65 \par Policy Interface:
66 ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
67 ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer(),
68 ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
73 TCPv4SocketProtocol provides an internet protocol stream socket based on the TCP protocol
76 This class is utilized as the protocol class of the ProtocolClientSocketHandle and
77 ProtocolServerSocketHandle via the Socket Handle typedefs above.
79 \see TCPv6SocketProtocol
81 class TCPv4SocketProtocol
82 : public ConcreteSocketProtocol<TCPv4Socket_Policy,TCPv4SocketProtocol>,
84 public BSDSocketProtocol,
85 public AddressableBSDSocketProtocol
88 ///////////////////////////////////////////////////////////////////////////
94 void init_client() const; ///< Create unconnected client socket
95 /**< \note This member is implicitly called from the
96 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
98 void init_client(INet4SocketAddress const & address) const;
99 ///< Create client socket and connect
100 /**< Creates a new client socket and connects to the given
103 \param[in] address remote address to connect to */
104 /**< \note This member is implicitly called from the
105 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
107 void init_server() const; ///< Create server socket
108 /**< \note This member is implicitly called from the
109 ProtocolServerSocketHandle::ProtocolServerSocketHandle()
111 void init_server(INet4SocketAddress const & address, unsigned backlog=1) const;
112 ///< Create server socket and listen
113 /**< Creates a new server socket, binds to \a address end
114 starts listening for new connections with a backlog of
115 \a backlog connections. It also enables reuseaddr().
117 \param[in] address address to listen on
118 \param[in] backlog size of the listen backlog */
119 /**< \note This member is implicitly called from the
120 ProtocolServerSocketHandle::ProtocolServerSocketHandle()
126 typedef ProtocolClientSocketHandle<TCPv4SocketProtocol> TCPv4ClientSocketHandle;
127 typedef ProtocolServerSocketHandle<TCPv4SocketProtocol> TCPv4ServerSocketHandle;
129 typedef MakeSocketPolicy<
131 INet6AddressingPolicy
132 >::policy TCPv6Socket_Policy;
134 /** \brief IPv6 TCP Socket Protocol
136 \par Socket Handle typedefs:
137 \ref TCPv6ClientSocketHandle (ProtocolClientSocketHandle), \ref TCPv6ServerSocketHandle
138 (ProtocolServerSocketHandle)
140 \par Policy Interface:
141 ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
142 ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer(),
143 ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
148 TCPv6SocketProtocol provides an internet protocol stream socket based on the TCP protocol
151 This class is utilized as the protocol class of the ProtocolClientSocketHandle and
152 ProtocolServerSocketHandle via the Socket Handle typedefs above.
154 \see TCPv4SocketProtocol
156 class TCPv6SocketProtocol
157 : public ConcreteSocketProtocol<TCPv6Socket_Policy,TCPv6SocketProtocol>,
159 public BSDSocketProtocol,
160 public AddressableBSDSocketProtocol
163 ///////////////////////////////////////////////////////////////////////////
164 // internal interface
166 ///\name Constructors
169 void init_client() const; ///< Create unconnected client socket
170 /**< \note This member is implicitly called from the
171 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
173 void init_client(INet6SocketAddress const & address) const;
174 ///< Create client socket and connect
175 /**< Creates a new client socket and connects to the given
178 \param[in] address remote address to connect to */
179 /**< \note This member is implicitly called from the
180 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
182 void init_server() const; ///< Create server socket
183 /**< \note This member is implicitly called from the
184 ProtocolServerSocketHandle::ProtocolServerSocketHandle()
186 void init_server(INet6SocketAddress const & address, unsigned backlog=1) const;
187 ///< Create server socket and listen
188 /**< Creates a new server socket, binds to \a address end
189 starts listening for new connections with a backlog of
190 \a backlog connections. It also enables reuseaddr().
192 \param[in] address address to listen on
193 \param[in] backlog size of the listen backlog */
194 /**< \note This member is implicitly called from the
195 ProtocolServerSocketHandle::ProtocolServerSocketHandle()
201 typedef ProtocolClientSocketHandle<TCPv6SocketProtocol> TCPv6ClientSocketHandle;
202 typedef ProtocolServerSocketHandle<TCPv6SocketProtocol> TCPv6ServerSocketHandle;
208 ///////////////////////////////hh.e////////////////////////////////////////
209 //#include "TCPSocketHandle.cci"
210 //#include "TCPSocketHandle.ct"
211 //#include "TCPSocketHandle.cti"
218 // c-file-style: "senf"
219 // indent-tabs-mode: nil
220 // ispell-local-dictionary: "american"
221 // compile-command: "scons -u test"
222 // comment-column: 40