53c843317919841a381db46d6b9816bb43768501
[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 "INetSocketProtocol.hh"
35 #include "UDPSocketProtocol.hh"
36 #include "../../../Socket/Protocols/BSDSocketProtocol.hh"
37 #include "../../../Socket/Protocols/DatagramSocketProtocol.hh"
38 #include "../../../Socket/FramingPolicy.hh"
39 #include "../../../Socket/CommunicationPolicy.hh"
40 #include "../../../Socket/ReadWritePolicy.hh"
41 #include "../../../Socket/ProtocolClientSocketHandle.hh"
42
43 //#include "ConnectedUDPSocketHandle.mpp"
44 ///////////////////////////////hh.p////////////////////////////////////////
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             ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
68
69         \par Address Type:
70             INet4Address
71         
72         ConnectedUDPv4SocketProtocol provides an internet protocol stream socket based on the UDP
73         protocol and IPv4 addressing.
74
75         This class is utilized as the protocol class of the ProtocolClientSocketHandle
76         via the Socket Handle typedefs above.
77
78         \see ConnectedUDPv6SocketProtocol
79      */
80     class ConnectedUDPv4SocketProtocol
81         : public ConcreteSocketProtocol<ConnectedUDPv4Socket_Policy, ConnectedUDPv4SocketProtocol>,
82           public UDPSocketProtocol,
83           public BSDSocketProtocol,
84           public DatagramSocketProtocol,
85           public AddressableBSDSocketProtocol
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     };
110
111     typedef ProtocolClientSocketHandle<
112         ConnectedUDPv4SocketProtocol> ConnectedUDPv4ClientSocketHandle;
113
114     typedef MakeSocketPolicy<
115         ConnectedUDPv4Socket_Policy,
116         INet6AddressingPolicy
117         >::policy  ConnectedUDPv6Socket_Policy;
118
119     /** \brief IPv6 UDP Socket Protocol, connected
120
121         \par Socket Handle typedefs:
122             \ref ConnectedUDPv6ClientSocketHandle (ProtocolClientSocketHandle)
123
124         \par Policy Interface:
125             ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
126             ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer(),
127             ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
128
129         \par Address Type:
130             INet6Address
131
132         ConnectedUDPv6SocketProtocol provides an internet protocol stream socket based on the UDP
133         protocol and IPv6 addressing.
134
135         This class is utilized as the protocol class of the ProtocolClientSocketHandle
136         via the Socket Handle typedefs above.
137
138         \see ConnectedUDPv4SocketProtocol
139      */
140     class ConnectedUDPv6SocketProtocol
141         : public ConcreteSocketProtocol<ConnectedUDPv6Socket_Policy, ConnectedUDPv6SocketProtocol>,
142           public UDPSocketProtocol,
143           public BSDSocketProtocol,
144           public DatagramSocketProtocol,
145           public AddressableBSDSocketProtocol
146     {
147     public:
148         ///////////////////////////////////////////////////////////////////////////
149         // internal interface
150
151         ///\name Constructors
152         ///@{
153
154         void init_client() const;       ///< Create unconnected client socket
155                                         /**< \note This member is implicitly called from the
156                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
157                                              constructor */
158         void init_client(INet6SocketAddress const & address) const;
159                                         ///< Create client socket and connect
160                                         /**< Creates a new client socket and connects to the given
161                                              address.
162
163                                              \param[in] address remote address to connect to */
164                                         /**< \note This member is implicitly called from the
165                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
166                                              constructor */
167
168         ///@}
169     };
170
171     typedef ProtocolClientSocketHandle<
172         ConnectedUDPv6SocketProtocol> ConnectedUDPv6ClientSocketHandle;
173
174     /// @}
175
176 }
177
178 ///////////////////////////////hh.e////////////////////////////////////////
179 //#include "ConnectedUDPSocketHandle.cci"
180 //#include "ConnectedUDPSocketHandle.ct"
181 //#include "ConnectedUDPSocketHandle.cti"
182 #endif
183
184 \f
185 // Local Variables:
186 // mode: c++
187 // fill-column: 100
188 // c-file-style: "senf"
189 // indent-tabs-mode: nil
190 // ispell-local-dictionary: "american"
191 // compile-command: "scons -u test"
192 // comment-column: 40
193 // End: