2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 // Stefan Bund <g0dil@berlios.de>
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.
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.
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.
22 \brief SocketSink public header */
24 #ifndef HH_SocketSink_
25 #define HH_SocketSink_ 1
28 #include "../Packets/Packets.hh"
29 #include "../Socket/ClientSocketHandle.hh"
30 #include "../Socket/SocketPolicy.hh"
31 #include "../Socket/ReadWritePolicy.hh"
32 #include "../Socket/FramingPolicy.hh"
33 #include "../Socket/CommunicationPolicy.hh"
35 #include "Connectors.hh"
37 //#include "SocketSink.mpp"
38 ///////////////////////////////hh.p////////////////////////////////////////
43 /** \brief Write helper for module::ActiveSocketSink / module::PassiveSocketSink
45 This write helper will write the packets completely as datagrams to the given socket.
50 typedef senf::ClientSocketHandle<
51 senf::MakeSocketPolicy< senf::WriteablePolicy,
52 senf::DatagramFramingPolicy,
53 senf::ConnectedCommunicationPolicy>::policy > Handle;
54 ///< Handle type supported by this writer
56 void operator()(Handle handle, Packet packet);
57 ///< Write \a packet to \a handle
58 /**< Write the complete \a packet as a datagram to \a
60 \param[in] handle Handle to write data to
61 \param[in] packet Packet to write */
70 /** \brief Output module writing data to arbitrary FileHandle
72 This output module will write data to a FileHandle object using a given \a Sink. This
73 output module is active. This requires the file handle to be able to signal its readiness to
74 accept more data via the Scheduler.
76 The default \a Sink is senf::ppi::PacketSink which will write out the complete packet to
79 A \a Sink must fulfill the following interface:
84 typedef unspecified Handle; // type of handle requested
85 SomeSink(); // default constructible
86 void operator()(Handle handle, Packet packet); // insertion function
89 Whenever a packet is received for sending, the \a Sink's \c operator() is called.
93 template <class Sink=PacketSink>
94 class ActiveSocketSink : public Module
96 SENF_PPI_MODULE(ActiveSocketSink);
99 typedef typename Sink::Handle Handle; ///< Handle type requested by writer
101 connector::ActiveInput input; ///< Input connector from which data is received
103 ActiveSocketSink(Handle handle); ///< Create new writer for the given handle
104 /**< Data will be written to \a handle using \a Sink.
105 \param[in] handle Handle to write data to */
114 /** \brief Output module writing data to arbitrary FileHandle
116 This output module will write data to a FileHandle object using a given \a Sink. This
117 output module is passive. This implies, that the output handle may not block. This also
118 implies, that data will probably get lost if written to fast for the underlying transport
119 mechanism. Either this is desired (like for a UDP socket) or some additional bandwidth
120 shaping needs to be used.
122 The default \a Sink is senf::ppi::PacketSink which will write out the complete packet to
125 The \a Sink must fulfill the following interface:
130 typedef unspecified Handle; // type of handle requested
131 SomeSink(); // default constructible
132 void operator()(Handle handle, Packet packet); // insertion function
135 Whenever a packet is received for sending, the \a Sink's \c operator() is called.
139 template <class Sink=PacketSink>
140 class PassiveSocketSink : public Module
142 SENF_PPI_MODULE(PassiveSocketSink);
145 typedef typename Sink::Handle Handle; ///< Handle type requested by writer
147 connector::PassiveInput input; ///< Input connector from which data is received
149 PassiveSocketSink(Handle handle); ///< Create new writer for the given handle
150 /**< Data will be written to \a handle using \a Sink.
151 \param[in] handle Handle to write data to */
163 ///////////////////////////////hh.e////////////////////////////////////////
164 #include "SocketSink.cci"
165 #include "SocketSink.ct"
166 //#include "SocketSink.cti"
173 // c-file-style: "senf"
174 // indent-tabs-mode: nil
175 // ispell-local-dictionary: "american"
176 // compile-command: "scons -u test"
177 // comment-column: 40