switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Socket / Protocols / INet / UDPSocketHandle.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_UDPSocketHandle_
36 #define HH_SENF_Socket_Protocols_INet_UDPSocketHandle_ 1
37
38 // Custom includes
39 #include "INetAddressing.hh"
40 #include "UDPSocketProtocol.hh"
41 #include "MulticastSocketProtocol.hh"
42 #include <senf/Socket/Protocols/BSDSocketProtocol.hh>
43 #include <senf/Socket/Protocols/DatagramSocketProtocol.hh>
44 #include <senf/Socket/FramingPolicy.hh>
45 #include <senf/Socket/CommunicationPolicy.hh>
46 #include <senf/Socket/ReadWritePolicy.hh>
47 #include <senf/Socket/ProtocolClientSocketHandle.hh>
48
49 //#include "UDPSocketHandle.mpp"
50 //-/////////////////////////////////////////////////////////////////////////////////////////////////
51
52 namespace senf {
53
54     /// \addtogroup concrete_protocol_group
55     //\{
56
57     typedef MakeSocketPolicy<
58         INet4AddressingPolicy,
59         DatagramFramingPolicy,
60         UnconnectedCommunicationPolicy,
61         ReadablePolicy,
62         WriteablePolicy
63         >::policy UDPv4Socket_Policy;   ///< Socket Policy of the UDPv4 Protocol
64
65     /** \brief IPv4 UDP Socket Protocol
66
67         \par Socket Handle typedefs:
68             \ref UDPv4ClientSocketHandle (ProtocolClientSocketHandle)
69
70         \par Policy Interface:
71             ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
72             ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local()
73
74         \par Address Type:
75             INet4SocketAddress
76
77         UDPv4SocketProtocol provides an internet protocol stream socket based on the UDP protocol
78         and IPv4 addressing.
79
80         This class is utilized as the protocol class of the ProtocolClientSocketHandle
81         via the Socket Handle typedefs above.
82
83         \see UDPv6SocketProtocol
84      */
85     class UDPv4SocketProtocol
86         : public ConcreteSocketProtocol<UDPv4Socket_Policy, UDPv4SocketProtocol>,
87           public UDPSocketProtocol,
88           public INet4MulticastSocketProtocol,
89           public BSDSocketProtocol,
90           public DatagramSocketProtocol,
91           public AddressableBSDSocketProtocol
92     {
93     public:
94         //-////////////////////////////////////////////////////////////////////////
95         // internal interface
96
97         ///\name Constructors
98         //\{
99
100         void init_client() const;       ///< Create unconnected client socket
101                                         /**< \note This member is implicitly called from the
102                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
103                                              constructor */
104         void init_client(INet4SocketAddress const & address) const;
105                                         ///< Create client socket and bind
106                                         /**< Creates a new client socket and bind to the given
107                                              address.
108                                              \param[in] address local address to bind to */
109                                         /**< \note This member is implicitly called from the
110                                             ProtocolClientSocketHandle::ProtocolClientSocketHandle()
111                                              constructor */
112
113         //\}
114
115     };
116
117     typedef ProtocolClientSocketHandle<UDPv4SocketProtocol> UDPv4ClientSocketHandle;
118
119     typedef MakeSocketPolicy<
120         UDPv4Socket_Policy,
121         INet6AddressingPolicy
122         >::policy UDPv6Socket_Policy;
123
124     /** \brief IPv6 UDP Socket Protocol
125
126         \par Socket Handle typedefs:
127         \ref UDPv6ClientSocketHandle (ProtocolClientSocketHandle)
128
129         \par Policy Interface:
130             ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
131             ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local()
132
133         \par Address Type:
134             INet6Address
135
136         UDPv6SocketProtocol provides an internet protocol stream socket based on the UDP protocol
137         and IPv6 addressing.
138
139         This class is utilized as the protocol class of the ProtocolClientSocketHandle
140         via the Socket Handle typedefs above.
141
142         \see UDPv4SocketProtocol
143      */
144     class UDPv6SocketProtocol
145         : public ConcreteSocketProtocol<UDPv6Socket_Policy, UDPv6SocketProtocol>,
146           public UDPSocketProtocol,
147           public INet6MulticastSocketProtocol,
148           public BSDSocketProtocol,
149           public DatagramSocketProtocol,
150           public AddressableBSDSocketProtocol
151     {
152     public:
153         //-////////////////////////////////////////////////////////////////////////
154         // internal interface
155
156         ///\name Constructors
157         //\{
158
159         void init_client() const;       ///< Create unconnected client socket
160                                         /**< \note This member is implicitly called from the
161                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
162                                              constructor */
163         void init_client(INet6SocketAddress const & address) const;
164                                         ///< Create client socket and connect
165                                         /**< Creates a new client socket and bind to the given
166                                              address.
167                                              \param[in] address local address to bind to */
168                                         /**< \note This member is implicitly called from the
169                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
170                                              constructor */
171
172         //\}
173     };
174
175     typedef ProtocolClientSocketHandle<UDPv6SocketProtocol> UDPv6ClientSocketHandle;
176
177     //\}
178
179 }
180
181 //-/////////////////////////////////////////////////////////////////////////////////////////////////
182 //#include "UDPSocketHandle.cci"
183 //#include "UDPSocketHandle.ct"
184 //#include "UDPSocketHandle.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: