connectedUnixDgramSocket (based on "old" socketlib)
[senf.git] / Socket / Protocols / UN / ConnectedUNDatagramSocketHandle.hh
1 // Copyright (C) 2007 
2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum NETwork research (NET)
4 //     David Wagner <david.wagner@fokus.fraunhofer.de>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20
21 /** \file
22     \brief ConnectedUNDatagramSocketHandle public header */
23
24 #ifndef CONNECTEDUNDATAGRAMSOCKETHANDLE_HH_
25 #define CONNECTEDUNDATAGRAMSOCKETHANDLE_HH_
26
27 // Custom includes
28 #include "UNAddressing.hh"
29 #include "UNProtocol.hh"
30 #include "../../../Socket/Protocols/BSDSocketProtocol.hh"
31 #include "../../../Socket/FramingPolicy.hh"
32 #include "../../../Socket/CommunicationPolicy.hh"
33 #include "../../../Socket/ReadWritePolicy.hh"
34 #include "../../../Socket/BufferingPolicy.hh"
35 #include "../../../Socket/ProtocolClientSocketHandle.hh"
36
37 //#include "UNDatagramSocketHandle.mpp"
38 ///////////////////////////////hh.p////////////////////////////////////////
39
40 namespace senf {
41
42     /// \addtogroup concrete_protocol_group
43     /// @{
44
45     typedef MakeSocketPolicy<
46         UNAddressingPolicy,
47         DatagramFramingPolicy,
48         ConnectedCommunicationPolicy,
49         ReadablePolicy,
50         WriteablePolicy,
51         SocketBufferingPolicy
52         >::policy ConnectedUNDatagramSocket_Policy;   ///< Socket Policy of the Unix Domain Datagram Protocol (connected)
53
54     /** \brief Unix Domain Datagram Socket Protocol (connected)
55
56         \par Socket Handle typedefs:
57             \ref ConnectedUNDatagramClientSocketHandle (ProtocolClientSocketHandle)
58
59         \par Policy Interface: (to be checked)
60             ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
61             ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local(),
62             ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
63
64         \par Address Type:
65             UNAddress
66
67         ConnectedUNDatagramSocketProtocol provides an datagram protocol socket based on the unix domain  addressing which operates in a connected mode.
68
69         This class is utilized as the protocol class of the ProtocolClientSocketHandle
70         via the Socket Handle typedefs above.
71
72     */
73     class ConnectedUNDatagramSocketProtocol
74         : public ConcreteSocketProtocol<ConnectedUNDatagramSocket_Policy>,
75           public UNProtocol, 
76           public BSDSocketProtocol,
77           public AddressableBSDSocketProtocol
78     {
79     public:
80         ///////////////////////////////////////////////////////////////////////////
81         // internal interface
82
83         ///\name Constructors
84         ///@{
85
86         void init_client() const;       ///< Create unconnected client socket
87                                         /**< \note This member is implicitly called from the
88                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
89                                              constructor */
90         void init_client(UNSocketAddress const & address) const; 
91                                         ///< Create client socket and connect
92                                         /**< Creates a new client socket and connects to the given
93                                              address.
94                                              \param[in] address peer address to connect to */
95                                         /**< \note This member is implicitly called from the
96                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
97                                              constructor */
98         
99         ///@}
100         ///\name Abstract Interface Implementation
101
102         std::auto_ptr<SocketProtocol> clone() const;
103
104         ///@}
105     };
106
107     typedef ProtocolClientSocketHandle<ConnectedUNDatagramSocketProtocol> ConnectedUNDatagramClientSocketHandle;
108
109 }
110
111 #endif /*CONNECTEDUNDATAGRAMSOCKETHANDLE_HH_*/