Fixed whitespace in all files (no tabs)
[senf.git] / Socket / CommunicationPolicy.hh
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <stefan.bund@fokus.fraunhofer.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 CommunicationPolicy public header
25  */
26
27 #ifndef HH_CommunicationPolicy_
28 #define HH_CommunicationPolicy_ 1
29
30 // Custom includes
31 #include "SocketPolicy.hh"
32 #include "AddressingPolicy.hh"
33 #include "FileHandle.hh"
34
35 //#include "CommunicationPolicy.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
37
38 struct sockaddr;
39
40 namespace senf {
41
42     /// \addtogroup policy_impl_group
43     /// @{
44
45     template <class Policy> class ServerSocketHandle;
46
47     /** \brief CommunicationPolicy for connected sockets
48
49         The ConnectedCommunicationPolicy provides support for standard BSD socket API based
50         connected communication. It provides the server side listen() and accept() members.
51      */
52     struct ConnectedCommunicationPolicy : public CommunicationPolicyBase
53     {
54         static void listen(FileHandle handle, unsigned backlog);
55                                         ///< Enable establishing new connections on the socket
56                                         /**< \param[in] handle socket handle to enable reception on
57                                              \param[in] backlog size of backlog queue
58
59                                              \fixme listen probably makes no sense without accpept,
60                                                  so listen() should debend on AddressingPolicy
61                                                  too. */
62         template <class Policy>
63         static int accept(ServerSocketHandle<Policy> handle,
64                           typename ServerSocketHandle<Policy>::Address & address,
65                           typename IfAddressingPolicyIsNot<Policy,NoAddressingPolicy>::type * = 0);
66                                         ///< accept a new connection on the socket.
67                                         /**< The accept() member will return a new client file
68                                              descriptor. This file descriptor will be used by the
69                                              ServerSocketHandle implementation to build a new
70                                              ClientSocketHandle for the new connection.
71
72                                              \param[in] handle socket handle to accept connection on
73                                              \param[out] address address of newly connected remote
74                                                  peer
75                                              \returns file descriptor of new client socket */
76     private:
77         static int do_accept(FileHandle handle, struct sockaddr * addr, unsigned len);
78     };
79
80     /** \brief CommunicationPolicy for unconnected sockets
81
82         This is different from UndefinedCommunicationPolicy (which is the same as
83         CommunicationPolicyBase). This policy class defines the communication policy -- it
84         explicitly states, that the socket does not support connected communication. This
85         effektively disables ther ServerSocketHandle.
86      */
87     struct UnconnectedCommunicationPolicy : public CommunicationPolicyBase
88     {};
89
90     /// @}
91
92 }
93
94
95 ///////////////////////////////hh.e////////////////////////////////////////
96 //#include "CommunicationPolicy.cci"
97 //#include "CommunicationPolicy.ct"
98 #include "CommunicationPolicy.cti"
99 #endif
100
101 \f
102 // Local Variables:
103 // mode: c++
104 // fill-column: 100
105 // c-file-style: "senf"
106 // indent-tabs-mode: nil
107 // ispell-local-dictionary: "american"
108 // End: