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 ReadPolicy and WritePolicy public header
26 \todo ReadWritePolicy.test.cc
29 #ifndef HH_ReadWritePolicy_
30 #define HH_ReadWritePolicy_ 1
33 #include "SocketPolicy.hh"
34 #include "ClientSocketHandle.hh"
35 #include "CommunicationPolicy.hh"
37 //#include "ReadWritePolicy.mpp"
38 ///////////////////////////////hh.p////////////////////////////////////////
45 /// \addtogroup policy_impl_group
48 /** \brief ReadPolicy for readable sockets
50 This policy provides support for readable sockets via the standard UNIX read/recvfrom system
51 cals. The concreate semantics of the read calls depend on the framing policy of the socket.
53 struct ReadablePolicy : public ReadPolicyBase
55 static unsigned read(FileHandle handle, char * buffer, unsigned size);
56 ///< read data from socket
57 /**< \param[in] handle socket handle to read from
58 \param[in] buffer address of buffer to write data to
59 \param[in] size size of buffer
60 \returns number of bytes read */
61 template <class Policy>
62 static unsigned readfrom(ClientSocketHandle<Policy> handle, char * buffer, unsigned size,
63 typename Policy::AddressingPolicy::Address & address,
64 typename IfCommunicationPolicyIs<Policy,UnconnectedCommunicationPolicy>::type * = 0);
65 ///< read data from socket returning peer address
66 /**< \param[in] handle socket handle to read from
67 \param[in] buffer address of buffer to write data to
68 \param[in] size size of buffer
69 \param[out] address peer address
70 \returns number of bytes read */
74 static unsigned do_readfrom(FileHandle handle, char * buffer, unsigned size,
75 struct ::sockaddr * addr, socklen_t len);
78 /** \brief ReadPolicy for unreadable sockets
80 This is different from UndefinedReadPolicy (which is the same as ReadPolicyBase). This
81 policy class defines the socket readability -- it explicitly states, that the socket does
84 struct NotReadablePolicy : public ReadPolicyBase
87 /** \brief WritePolicy for writeable sockets
89 This policy provides support for writable sockets via the standard UNIX write/sendto system
90 cals. The concreate semantics of the write calls depend on the framing policy of the socket.
92 struct WriteablePolicy : public WritePolicyBase
94 template <class Policy>
95 static unsigned write(ClientSocketHandle<Policy> handle, char const * buffer, unsigned size,
96 typename IfCommunicationPolicyIs<Policy,ConnectedCommunicationPolicy>::type * = 0);
97 ///< write data to socket
98 /**< This member is only enabled if the socket uses
99 connected communication. Otherwise the communication
100 partner must be specified explicitly using the sendto
103 \param[in] handle socket handle to write data to
104 \param[in] buffer address of buffer to send
105 \param[in] size number of bytes to write
106 \returns number of bytes written */
107 template <class Policy>
108 static unsigned writeto(ClientSocketHandle<Policy> handle,
109 typename boost::call_traits<typename Policy::AddressingPolicy::Address>::param_type addr,
110 char const * buffer, unsigned size,
111 typename IfCommunicationPolicyIs<Policy,UnconnectedCommunicationPolicy>::type * = 0);
112 ///< write data to socket sending to given peer
113 /**< This member is only enabled if the socket uses
114 unconnected communication. Otherwise no target may be
115 specified since it is implied in the connection.
117 \param[in] handle socket handle to write data to
118 \param[in] buffer address of buffer to send
119 \param[in] size number of bytes to write
120 \param[in] address peer to send data to
121 \returns number of bytes written
125 static unsigned do_write(FileHandle handle, char const * buffer, unsigned size);
126 static unsigned do_writeto(FileHandle handle, char const * buffer, unsigned size,
127 struct sockaddr * addr, socklen_t len);
130 /** \brief WritePolicy for unwriteable sockets
132 This is different from UndefinedWritePolicy (which is the same as WritePolicyBase). This
133 policy class defines the socket writeability -- it explicitly states, that the socket does
136 struct NotWriteablePolicy : public WritePolicyBase
144 ///////////////////////////////hh.e////////////////////////////////////////
145 //#include "ReadWritePolicy.cci"
146 //#include "ReadWritePolicy.ct"
147 #include "ReadWritePolicy.cti"
153 // c-file-style: "senf"