NEW FILE HEADER / COPYRIGHT FORMAT
[senf.git] / Socket / Protocols / UN / UNProtocol.hh
1 // Copyright (C) 2007 
2 // Fraunhofer Institute for Open Communication Systems (FOKUS) 
3 // Kompetenzzentrum NETwork research (NET)
4 //     David Wagner <dw6@berlios.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 UNProtocol public header */
23
24 #ifndef HH_UNProtocol_
25 #define HH_UNProtocol_ 1
26
27 // Custom includes
28 #include "../../../Socket/SocketProtocol.hh"
29 #include "UNAddressing.hh"
30 #include "../../../Socket/ClientSocketHandle.hh"
31 #include "../../../Socket/CommunicationPolicy.hh"
32
33 //#include "UNProtocol.mpp"
34 ///////////////////////////////hh.p////////////////////////////////////////
35
36 namespace senf {
37
38     /// \addtogroup protocol_facets_group
39     /// @{
40
41     /** \brief Protocol facet providing Unix Domain Addressing related API
42
43         This protocol facet introduces all the socket api protocol members which are related to Unix 
44         Domain addressing.
45
46         \todo connect() is only available on stream sockets. We want to access bind() and connect()
47         via the ClientSocketHandle -> see SocketProtocol todo point
48      */
49     class UNProtocol
50         : public virtual SocketProtocol
51     {
52     public:
53         void connect(UNSocketAddress const & address) const; ///< Connect to a  unix domain socket 
54                                         /**< \todo make this obsolete by allowing access to the
55                                              ClientSocketHandle from ConcreateSocketProtocol
56                                              \param[in] address Address to connect to */
57         void bind(UNSocketAddress const & address) const; ///< Set local socket address (path)
58                                         /**< \todo make this obsolete by allowing access to the
59                                              ClientSocketHandle from ConcreateSocketProtocol
60                                              \param[in] address Address to set */
61         
62         virtual void close() const;   ///< Close socket
63                               /**< This override will automatically \c shutdown() the
64                                    socket whenever it is closed.
65                                    \throws senf::SystemException */  
66         virtual void terminate() const;       ///< Forcibly close socket
67                                         /**< This override will automatically \c shutdown() the
68                                            socket whenever it is called. Additionally it will
69                                            disable SO_LINGER to ensure, that v_terminate will not
70                                            block. Like the overriden method, this member will ignore
71                                            failures and will never throw. It therefore safe to be
72                                            called from a destructor. */        ///\name Abstract Interface Implementation
73         ///@{
74
75          unsigned available() const;
76          bool eof() const;
77          
78     private:
79         void check_and_unlink() const;  
80       
81         std::string path_;
82     };
83 }
84
85 ///////////////////////////////hh.e////////////////////////////////////////
86 //#include "UNProtocol.cci"
87 //#include "UNProtocol.ct"
88 //#include "UNProtocol.cti"
89 #endif
90
91 \f
92 // Local Variables:
93 // mode: c++
94 // fill-column: 100
95 // comment-column: 40
96 // c-file-style: "senf"
97 // indent-tabs-mode: nil
98 // ispell-local-dictionary: "american"
99 // compile-command: "scons -u test"
100 // End: