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 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 "BSDSocketProtocol.hh"
37 #include "FramingPolicy.hh"
38 #include "CommunicationPolicy.hh"
39 #include "ReadWritePolicy.hh"
40 #include "BufferingPolicy.hh"
41 #include "ProtocolClientSocketHandle.hh"
42 #include "ProtocolServerSocketHandle.hh"
44 //#include "TCPSocketHandle.mpp"
45 ///////////////////////////////hh.p////////////////////////////////////////
49 /// \addtogroup concrete_protocol_group
52 typedef MakeSocketPolicy<
53 INet4AddressingPolicy,
55 ConnectedCommunicationPolicy,
59 >::policy TCPv4Socket_Policy; ///< Socket Policy of the TCPv4 Protocol
61 /** \brief IPv4 TCP Socket Protocol
63 \par Socket Handle typedefs:
64 \ref TCPv4ClientSocketHandle (ProtocolClientSocketHandle), \ref TCPv4ServerSocketHandle
65 (ProtocolServerSocketHandle)
67 \par Protocol Interface:
68 ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
69 ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer(),
70 ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
75 TCPv4SocketProtocol provides an internet protocol stream socket based on the TCP protocol
78 This class is utilized as the protocol class of the ProtocolClientSocketHandle and
79 ProtocolServerSocketHandle via the Socket Handle typedefs above.
81 \see TCPv6SocketProtocol
83 class TCPv4SocketProtocol
84 : public ConcreteSocketProtocol<TCPv4Socket_Policy>,
87 public BSDSocketProtocol,
88 public AddressableBSDSocketProtocol
91 ///////////////////////////////////////////////////////////////////////////
97 void init_client() const; ///< Create unconnected client socket
98 /**< \note This member is implicitly called from the
99 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
101 void init_client(INet4Address const & address) const;
102 ///< Create client socket and connect
103 /**< Creates a new client socket and connects to the given
106 \param[in] address remote address to connect to */
107 /**< \note This member is implicitly called from the
108 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
110 void init_server() const; ///< Create server socket
111 /**< \note This member is implicitly called from the
112 ProtocolServerSocketHandle::ProtocolServerSocketHandle()
114 void init_server(INet4Address const & address, unsigned backlog=1) const;
115 ///< Create server socket and listen
116 /**< Creates a new server socket, binds to \a address end
117 starts listening for new connections with a backlog of
118 \a backlog connections. It also enables reuseaddr().
120 \param[in] address address to listen on
121 \param[in] backlog size of the listen backlog */
122 /**< \note This member is implicitly called from the
123 ProtocolServerSocketHandle::ProtocolServerSocketHandle()
127 ///\name Abstract Interface Implementation
129 std::auto_ptr<SocketProtocol> clone() const;
134 typedef ProtocolClientSocketHandle<TCPv4SocketProtocol> TCPv4ClientSocketHandle;
135 typedef ProtocolServerSocketHandle<TCPv4SocketProtocol> TCPv4ServerSocketHandle;
137 typedef MakeSocketPolicy<
139 INet6AddressingPolicy
140 >::policy TCPv6Socket_Policy;
142 /** \brief IPv6 TCP Socket Protocol
144 \par Socket Handle typedefs:
145 \ref TCPv6ClientSocketHandle (ProtocolClientSocketHandle), \ref TCPv6ServerSocketHandle
146 (ProtocolServerSocketHandle)
148 \par Protocol Interface:
149 ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
150 ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer(),
151 ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
156 TCPv6SocketProtocol provides an internet protocol stream socket based on the TCP protocol
159 This class is utilized as the protocol class of the ProtocolClientSocketHandle and
160 ProtocolServerSocketHandle via the Socket Handle typedefs above.
162 \see TCPv4SocketProtocol
166 class TCPv6SocketProtocol
167 : public ConcreteSocketProtocol<TCPv6Socket_Policy>,
170 public BSDSocketProtocol,
171 public AddressableBSDSocketProtocol
175 typedef ProtocolClientSocketHandle<TCPv6SocketProtocol> TCPv6ClientSocketHandle;
176 typedef ProtocolServerSocketHandle<TCPv6SocketProtocol> TCPv6ServerSocketHandle;
182 ///////////////////////////////hh.e////////////////////////////////////////
183 //#include "TCPSocketHandle.cci"
184 //#include "TCPSocketHandle.ct"
185 //#include "TCPSocketHandle.cti"
191 // c-file-style: "senf"