589defaf7836ba8cf24adefba7d1c80b6edc5319
[senf.git] / senf / 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_SENF_Socket_Protocols_INet_ConnectedUDPSocketHandle_
31 #define HH_SENF_Socket_Protocols_INet_ConnectedUDPSocketHandle_ 1
32
33 // Custom includes
34 #include "INetAddressing.hh"
35 #include "UDPSocketProtocol.hh"
36 #include <senf/Socket/Protocols/BSDSocketProtocol.hh>
37 #include <senf/Socket/Protocols/DatagramSocketProtocol.hh>
38 #include <senf/Socket/FramingPolicy.hh>
39 #include <senf/Socket/CommunicationPolicy.hh>
40 #include <senf/Socket/ReadWritePolicy.hh>
41 #include <senf/Socket/ProtocolClientSocketHandle.hh>
42
43 //#include "ConnectedUDPSocketHandle.mpp"
44 //-/////////////////////////////////////////////////////////////////////////////////////////////////
45
46 namespace senf {
47
48     /// \addtogroup concrete_protocol_group
49     //\{
50
51     typedef MakeSocketPolicy<
52         INet4AddressingPolicy,
53         DatagramFramingPolicy,
54         ConnectedCommunicationPolicy,
55         ReadablePolicy,
56         WriteablePolicy
57         >::policy ConnectedUDPv4Socket_Policy;   ///< Socket Policy of the UDPv4 Protocol
58
59     /** \brief IPv4 UDP Socket Protocol, connected
60
61         \par Socket Handle typedefs:
62             \ref ConnectedUDPv4ClientSocketHandle (ProtocolClientSocketHandle)
63
64         \par Policy Interface:
65             ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
66             ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer()
67
68         \par Address Type:
69             INet4SocketAddress
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, ConnectedUDPv4SocketProtocol>,
81           public UDPSocketProtocol,
82           public BSDSocketProtocol,
83           public DatagramSocketProtocol,
84           public AddressableBSDSocketProtocol
85     {
86     public:
87         //-////////////////////////////////////////////////////////////////////////
88         // internal interface
89
90         ///\name Constructors
91         //\{
92
93         void init_client() const;       ///< Create unconnected client socket
94                                         /**< \note This member is implicitly called from the
95                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
96                                              constructor */
97         void init_client(INet4SocketAddress const & address) const;
98                                         ///< Create client socket and connect
99                                         /**< Creates a new client socket and connects to the given
100                                              address.
101
102                                              \param[in] address remote address to connect to */
103                                         /**< \note This member is implicitly called from the
104                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
105                                              constructor */
106
107         //\}
108     };
109
110     typedef ProtocolClientSocketHandle<
111         ConnectedUDPv4SocketProtocol> ConnectedUDPv4ClientSocketHandle;
112
113     typedef MakeSocketPolicy<
114         ConnectedUDPv4Socket_Policy,
115         INet6AddressingPolicy
116         >::policy  ConnectedUDPv6Socket_Policy;
117
118     /** \brief IPv6 UDP Socket Protocol, connected
119
120         \par Socket Handle typedefs:
121             \ref ConnectedUDPv6ClientSocketHandle (ProtocolClientSocketHandle)
122
123         \par Policy Interface:
124             ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
125             ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer()
126
127         \par Address Type:
128             INet6Address
129
130         ConnectedUDPv6SocketProtocol provides an internet protocol stream socket based on the UDP
131         protocol and IPv6 addressing.
132
133         This class is utilized as the protocol class of the ProtocolClientSocketHandle
134         via the Socket Handle typedefs above.
135
136         \see ConnectedUDPv4SocketProtocol
137      */
138     class ConnectedUDPv6SocketProtocol
139         : public ConcreteSocketProtocol<ConnectedUDPv6Socket_Policy, ConnectedUDPv6SocketProtocol>,
140           public UDPSocketProtocol,
141           public BSDSocketProtocol,
142           public DatagramSocketProtocol,
143           public AddressableBSDSocketProtocol
144     {
145     public:
146         //-////////////////////////////////////////////////////////////////////////
147         // internal interface
148
149         ///\name Constructors
150         //\{
151
152         void init_client() const;       ///< Create unconnected client socket
153                                         /**< \note This member is implicitly called from the
154                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
155                                              constructor */
156         void init_client(INet6SocketAddress const & address) const;
157                                         ///< Create client socket and connect
158                                         /**< Creates a new client socket and connects to the given
159                                              address.
160
161                                              \param[in] address remote address to connect to */
162                                         /**< \note This member is implicitly called from the
163                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
164                                              constructor */
165
166         //\}
167     };
168
169     typedef ProtocolClientSocketHandle<
170         ConnectedUDPv6SocketProtocol> ConnectedUDPv6ClientSocketHandle;
171
172     //\}
173
174 }
175
176 //-/////////////////////////////////////////////////////////////////////////////////////////////////
177 //#include "ConnectedUDPSocketHandle.cci"
178 //#include "ConnectedUDPSocketHandle.ct"
179 //#include "ConnectedUDPSocketHandle.cti"
180 #endif
181
182 \f
183 // Local Variables:
184 // mode: c++
185 // fill-column: 100
186 // c-file-style: "senf"
187 // indent-tabs-mode: nil
188 // ispell-local-dictionary: "american"
189 // compile-command: "scons -u test"
190 // comment-column: 40
191 // End: