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 SocketWriter public header */
24 #ifndef HH_SocketWriter_
25 #define HH_SocketWriter_ 1
28 #include "Packets/Packet.hh"
30 #include "Connector.hh"
32 //#include "SocketWriter.mpp"
33 ///////////////////////////////hh.p////////////////////////////////////////
38 /** \brief Write helper for module::ActiveSocketWriter / module::PassiveSocketWriter
40 This write helper will write the packets completely as datagrams to the given socket.
45 typedef senf::ClientSocketHandle<
46 senf::MakeSocketPolicy< senf::WriteablePolicy,
47 senf::DatagramFramingPolicy > > Handle;
48 ///< Handle type supported by this writer
50 void operator()(Handle handle, Packet::ptr packet);
51 ///< Write \a packet to \a handle
52 /**< Write the complete \a packet as a datagram to \a
54 \param[in] handle Handle to write data to
55 \param[in] packet Packet to write */
64 /** \brief Output module writing data to arbitrary FileHandle
66 This output module will write data to a FileHandle object using a given \a Writer. This
67 output module is active. This requires the file handle to be able to signal its readiness to
68 accept more data via the Scheduler.
70 The \a Writer must fulfill the following interface:
75 typedef unspecified Handle; // type of handle requested
76 SomeWriter(); // default constructible
77 void operator()(Handle handle, Packet::ptr packet); // insertion function
81 template <class Writer=PacketWriter>
82 class ActiveSocketWriter : public Module
85 typedef typename Writer:Handle Handle; ///< Handle type requested by writer
87 connector::ActiveInput input; ///< Input connector from which data is received
89 ActiveSocketWriter(Handle handle); ///< Create new writer for the given handle
90 /**< Data will be written to \a handle using \a Writer.
91 \param[in] handle Handle to write data to */
94 /** \brief Output module writing data to arbitrary FileHandle
96 This output module will write data to a FileHandle object using a given \a Writer. This
97 output module is passive. This implies, that the output handle may not block. This also
98 implies, that data will probably get lost if written to fast for the underlying transport
99 mechanism. Either this is desired (like for a UDP socket) or some additional bandwidth
100 shaping needs to be used.
102 The \a Writer must fulfill the following interface:
107 typedef unspecified Handle; // type of handle requested
108 SomeWriter(); // default constructible
109 void operator()(Handle handle, Packet::ptr packet); // insertion function
113 template <class Writer=PacketWriter>
114 class PassiveSocketWriter : public Module
117 typedef typename Writer:Handle Handle; ///< Handle type requested by writer
119 connector::PassiveInput input; ///< Input connector from which data is received
121 ActiveSocketWriter(Handle handle); ///< Create new writer for the given handle
122 /**< Data will be written to \a handle using \a Writer.
123 \param[in] handle Handle to write data to */
129 ///////////////////////////////hh.e////////////////////////////////////////
130 //#include "SocketWriter.cci"
131 //#include "SocketWriter.ct"
132 //#include "SocketWriter.cti"
139 // c-file-style: "senf"
140 // indent-tabs-mode: nil
141 // ispell-local-dictionary: "american"
142 // compile-command: "scons -u test"
143 // comment-column: 40