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