2 The software in this package is distributed under the GNU General
3 Public License version 2 (with a special exception described below).
5 A copy of GNU General Public License (GPL) is included in this distribution,
6 in the file COPYING.GPL.
8 As a special exception, if other files instantiate templates or use macros
9 or inline functions from this file, or you compile this file and link it
10 with other works to produce a work based on this file, this file
11 does not by itself cause the resulting work to be covered
12 by the GNU General Public License.
14 However the source code for this file must still be made available
15 in accordance with section (3) of the GNU General Public License.
17 This exception does not invalidate any other reasons why a work based
18 on this file might be covered by the GNU General Public License.
22 * @brief the "glue" between libt2n and AsyncIo framework.
24 * contains our own server and client class which should fit into the asnychronous way of "AsyncIo".
25 * We use our own classes since the libt2n socket classes are made for synchronous operation
26 * which can lead to problems even if we import the connection fd's into "AsyncIo"...
28 * @author Reinhard Pfau \<reinhard.pfau@intra2net.com\>
30 * @copyright © Copyright 2008 by Intra2net AG
32 * @todo support for TCP/IP connections.
35 #ifndef __CONND_GLUE_T2N_HPP__
36 #define __CONND_GLUE_T2N_HPP__
41 #include <async_io.hpp>
42 #include <async_socket.hpp>
43 #include <pointer_func.hpp>
44 #include <boost/shared_ptr.hpp>
45 #include <boost/weak_ptr.hpp>
46 #include <boost/signal.hpp>
55 * @brief specialized version of the libt2n client connection which fits into the AsyncIo framework.
58 class T2NClientConnection
59 : public libt2n::client_connection
63 T2NClientConnection();
64 virtual ~T2NClientConnection();
68 bool reopen(bool force= false);
72 ** overloaded methods from libt2n classes:
79 T2NClientConnection( AsyncIo::IOImplementationPtr connection );
86 ** overloaded methods from t2n classes:
89 virtual void real_write(const std::string& data);
91 virtual bool fill_buffer(long long usec_timeout=-1,long long* usec_timeout_remaining=NULL);
95 AsyncIo::IOImplementationPtr m_real_connection;
99 }; // eo class T2NClientConnection
102 typedef boost::shared_ptr< T2NClientConnection > T2NClientConnectionPtr;
107 typedef boost::shared_ptr< T2NServerBase > T2NServerBasePtr;
108 typedef boost::weak_ptr< T2NServerBase > T2NServerBaseWeakPtr;
111 * @brief specialized version of the libt2n server connection which fits into the AsyncIo framework.
114 class T2NServerConnection
115 : public libt2n::server_connection
117 friend class T2NServerBase;
120 T2NServerConnection();
121 virtual ~T2NServerConnection();
125 ** overloaded methods from libt2n classes:
128 virtual void close();
133 T2NServerBasePtr server,
134 AsyncIo::IOImplementationPtr connection,
141 bool low_fill_buffer(bool wait, long long usec_timeout=-1, long long* usec_timeout_remaining=NULL);
144 ** overloaded methods from t2n classes:
147 virtual void real_write(const std::string& data);
149 virtual bool fill_buffer(long long usec_timeout=-1,long long* usec_timeout_remaining=NULL);
154 AsyncIo::IOImplementationPtr m_real_connection;
155 T2NServerBaseWeakPtr m_server_weak_ptr;
159 }; // eo class T2NServerConnection
164 * @brief base server class for handling server ports for libt2n.
166 * Needs to be derived for the real type of connection (unix, IPv4, etc.).
168 * Does all necessary connection handling and realizes the abstract methods from
169 * the libt2n::server class.
172 : public libt2n::server
173 , virtual public SharedBase
176 virtual ~T2NServerBase();
181 ** overloaded methods from t2n classes:
184 virtual bool fill_buffer(long long usec_timeout=-1, long long* timeout_remaining=NULL);
188 boost::signal< void() > m_signal_client_got_new_data;
192 T2NServerBase( AsyncIo::ServerSocketBaseImplementationPtr server_port);
194 void newConnectionSlot(AsyncIo::IOImplementationPtr io_ptr);
196 void clientGotNewDataSlot();
199 ** overloaded methods from t2n classes:
202 virtual bool fill_connection_buffers(void);
207 AsyncIo::ServerSocketBaseImplementationPtr m_server_port;
208 bool m_new_data_available;
210 }; // eo T2NServerBase
213 typedef boost::shared_ptr< T2NServerBase > T2NServerBasePtr;
216 T2NServerBasePtr createT2NUnixServerPort(const std::string& path, int mode= 0600);
218 T2NClientConnectionPtr createT2NUnixClientConnection(const std::string& path);
221 } // eo namespace AsyncIo