Merged revisions 570-572,574-575,578-579,581-595,598-611 via svnmerge from
[senf.git] / Socket / Protocols / INet / ConnectedUDPSocketHandle.hh
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institute for Open Communication Systems (FOKUS) 
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY 
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief UDPv4SocketHandle and UDPv6SocketHandle public header
25
26     \todo Implement possibly non-blocking connect and SO_ERROR in the
27     protocol interface
28  */
29
30 #ifndef HH_ConnectedUDPSocketHandle_
31 #define HH_ConnectedUDPSocketHandle_ 1
32
33 // Custom includes
34 #include "INetProtocol.hh"
35 #include "UDPProtocol.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
42 //#include "ConnectedUDPSocketHandle.mpp"
43 ///////////////////////////////hh.p////////////////////////////////////////
44
45 namespace senf {
46
47     /// \addtogroup concrete_protocol_group
48     /// @{
49
50     typedef MakeSocketPolicy<
51         INet4AddressingPolicy,
52         DatagramFramingPolicy,
53         ConnectedCommunicationPolicy,
54         ReadablePolicy,
55         WriteablePolicy
56         >::policy ConnectedUDPv4Socket_Policy;   ///< Socket Policy of the UDPv4 Protocol
57
58     /** \brief IPv4 UDP Socket Protocol, connected
59
60         \par Socket Handle typedefs:
61             \ref ConnectedUDPv4ClientSocketHandle (ProtocolClientSocketHandle)
62
63         \par Policy Interface:
64             ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
65             ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer(),
66             ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
67
68         \par Address Type:
69             INet4Address
70         
71         ConnectedUDPv4SocketProtocol provides an internet protocol stream socket based on the UDP
72         protocol and IPv4 addressing.
73
74         This class is utilized as the protocol class of the ProtocolClientSocketHandle
75         via the Socket Handle typedefs above.
76
77         \see ConnectedUDPv6SocketProtocol
78      */
79     class ConnectedUDPv4SocketProtocol
80         : public ConcreteSocketProtocol<ConnectedUDPv4Socket_Policy>,
81           public IPv4Protocol,
82           public UDPProtocol,
83           public BSDSocketProtocol,
84           public AddressableBSDSocketProtocol,
85           public senf::pool_alloc_mixin<ConnectedUDPv4SocketProtocol>
86     {
87     public:
88         ///////////////////////////////////////////////////////////////////////////
89         // internal interface
90
91         ///\name Constructors
92         ///@{
93
94         void init_client() const;       ///< Create unconnected client socket
95                                         /**< \note This member is implicitly called from the
96                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
97                                              constructor */
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
101                                              address.
102
103                                              \param[in] address remote address to connect to */
104                                         /**< \note This member is implicitly called from the
105                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
106                                              constructor */
107
108         ///@}
109         ///\name Abstract Interface Implementation
110
111         std::auto_ptr<SocketProtocol> clone() const;
112
113         ///@}
114     };
115
116     typedef ProtocolClientSocketHandle<
117         ConnectedUDPv4SocketProtocol> ConnectedUDPv4ClientSocketHandle;
118
119     typedef MakeSocketPolicy<
120         ConnectedUDPv4Socket_Policy,
121         INet6AddressingPolicy
122         >::policy  ConnectedUDPv6Socket_Policy;
123
124     /** \brief IPv6 UDP Socket Protocol, connected
125
126         \par Socket Handle typedefs:
127             \ref ConnectedUDPv6ClientSocketHandle (ProtocolClientSocketHandle)
128
129         \par Policy Interface:
130             ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
131             ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer(),
132             ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
133
134         \par Address Type:
135             INet6Address
136
137         ConnectedUDPv6SocketProtocol provides an internet protocol stream socket based on the UDP
138         protocol and IPv6 addressing.
139
140         This class is utilized as the protocol class of the ProtocolClientSocketHandle
141         via the Socket Handle typedefs above.
142
143         \see ConnectedUDPv4SocketProtocol
144      */
145     class ConnectedUDPv6SocketProtocol
146         : public ConcreteSocketProtocol<ConnectedUDPv6Socket_Policy>,
147           public IPv6Protocol,
148           public UDPProtocol,
149           public BSDSocketProtocol,
150           public AddressableBSDSocketProtocol,
151           public senf::pool_alloc_mixin<ConnectedUDPv6SocketProtocol>
152     {
153     public:
154         ///////////////////////////////////////////////////////////////////////////
155         // internal interface
156
157         ///\name Constructors
158         ///@{
159
160         void init_client() const;       ///< Create unconnected client socket
161                                         /**< \note This member is implicitly called from the
162                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
163                                              constructor */
164         void init_client(INet6SocketAddress const & address) const;
165                                         ///< Create client socket and connect
166                                         /**< Creates a new client socket and connects to the given
167                                              address.
168
169                                              \param[in] address remote address to connect to */
170                                         /**< \note This member is implicitly called from the
171                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
172                                              constructor */
173
174         ///@}
175         ///\name Abstract Interface Implementation
176
177         std::auto_ptr<SocketProtocol> clone() const;
178
179         ///@}
180     };
181
182     typedef ProtocolClientSocketHandle<
183         ConnectedUDPv6SocketProtocol> ConnectedUDPv6ClientSocketHandle;
184
185     /// @}
186
187 }
188
189 ///////////////////////////////hh.e////////////////////////////////////////
190 //#include "ConnectedUDPSocketHandle.cci"
191 //#include "ConnectedUDPSocketHandle.ct"
192 //#include "ConnectedUDPSocketHandle.cti"
193 #endif
194
195 \f
196 // Local Variables:
197 // mode: c++
198 // fill-column: 100
199 // c-file-style: "senf"
200 // indent-tabs-mode: nil
201 // ispell-local-dictionary: "american"
202 // compile-command: "scons -u test"
203 // comment-column: 40
204 // End: