4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <stefan.bund@fokus.fraunhofer.de>
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.
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.
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.
24 \brief CommunicationPolicy public header
27 #ifndef HH_CommunicationPolicy_
28 #define HH_CommunicationPolicy_ 1
31 #include "SocketPolicy.hh"
32 #include "AddressingPolicy.hh"
33 #include "FileHandle.hh"
35 //#include "CommunicationPolicy.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
42 /// \addtogroup policy_impl_group
45 template <class Policy> class ServerSocketHandle;
47 /** \brief CommunicationPolicy for connected sockets
49 The ConnectedCommunicationPolicy provides support for standard BSD socket API based
50 connected communication. It provides the server side listen() and accept() members.
52 struct ConnectedCommunicationPolicy : public CommunicationPolicyBase
55 template <class Policy>
56 static void listen(ServerSocketHandle<Policy> handle, unsigned backlog,
57 typename IfAddressingPolicyIsNot<Policy,NoAddressingPolicy>::type * = 0);
59 template <class Policy>
60 static void listen(ServerSocketHandle<Policy> handle, unsigned backlog);
61 ///< Enable establishing new connections on the socket
62 /**< \param[in] handle socket handle to enable reception on
63 \param[in] backlog size of backlog queue */
67 template <class Policy>
68 static int accept(ServerSocketHandle<Policy> handle,
69 typename ServerSocketHandle<Policy>::Address & address,
70 typename IfAddressingPolicyIsNot<Policy,NoAddressingPolicy>::type * = 0);
72 template <class Policy>
73 static int accept(ServerSocketHandle<Policy> handle,
74 typename ServerSocketHandle<Policy>::Address & address);
75 ///< accept a new connection on the socket.
76 /**< The accept() member will return a new client file
77 descriptor. This file descriptor will be used by the
78 ServerSocketHandle implementation to build a new
79 ClientSocketHandle for the new connection.
81 \param[in] handle socket handle to accept connection on
82 \param[out] address address of newly connected remote
84 \returns file descriptor of new client socket */
88 static void do_listen(FileHandle handle, unsigned backlog);
89 static int do_accept(FileHandle handle, struct sockaddr * addr, unsigned len);
92 /** \brief CommunicationPolicy for unconnected sockets
94 This is different from UndefinedCommunicationPolicy (which is the same as
95 CommunicationPolicyBase). This policy class defines the communication policy -- it
96 explicitly states, that the socket does not support connected communication. This
97 effectively disables the ServerSocketHandle.
99 struct UnconnectedCommunicationPolicy : public CommunicationPolicyBase
107 ///////////////////////////////hh.e////////////////////////////////////////
108 //#include "CommunicationPolicy.cci"
109 //#include "CommunicationPolicy.ct"
110 #include "CommunicationPolicy.cti"
117 // c-file-style: "senf"
118 // indent-tabs-mode: nil
119 // ispell-local-dictionary: "american"
120 // compile-command: "scons -u test"
121 // comment-column: 40