3 * @brief the "glue" between libt2n and AsyncIo framework.
5 * contains our own server and client class which should fit into the asnychronous way of "AsyncIo".
6 * We use our own classes since the libt2n socket classes are made for synchronous operation
7 * which can lead to problems even if we import the connection fd's into "AsyncIo"...
9 * @author Reinhard Pfau \<reinhard.pfau@intra2net.com\>
11 * @copyright © Copyright 2008 by Intra2net AG
13 * @contact info@intra2net.com
15 * @todo support for TCP/IP connections.
18 #ifndef __CONND_GLUE_T2N_HPP__
19 #define __CONND_GLUE_T2N_HPP__
24 #include <async_io.hpp>
25 #include <async_socket.hpp>
26 #include <pointer_func.hpp>
27 #include <boost/shared_ptr.hpp>
28 #include <boost/weak_ptr.hpp>
29 #include <boost/signal.hpp>
38 * @brief specialized version of the libt2n client connection which fits into the AsyncIo framework.
41 class T2NClientConnection
42 : public libt2n::client_connection
46 T2NClientConnection();
47 virtual ~T2NClientConnection();
51 bool reopen(bool force= false);
55 ** overloaded methods from libt2n classes:
62 T2NClientConnection( AsyncIo::IOImplementationPtr connection );
69 ** overloaded methods from t2n classes:
72 virtual void real_write(const std::string& data);
74 virtual bool fill_buffer(long long usec_timeout=-1,long long* usec_timeout_remaining=NULL);
78 AsyncIo::IOImplementationPtr m_real_connection;
82 }; // eo class T2NClientConnection
85 typedef boost::shared_ptr< T2NClientConnection > T2NClientConnectionPtr;
90 typedef boost::shared_ptr< T2NServerBase > T2NServerBasePtr;
91 typedef boost::weak_ptr< T2NServerBase > T2NServerBaseWeakPtr;
94 * @brief specialized version of the libt2n server connection which fits into the AsyncIo framework.
97 class T2NServerConnection
98 : public libt2n::server_connection
100 friend class T2NServerBase;
103 T2NServerConnection();
104 virtual ~T2NServerConnection();
108 ** overloaded methods from libt2n classes:
111 virtual void close();
116 T2NServerBasePtr server,
117 AsyncIo::IOImplementationPtr connection,
124 bool low_fill_buffer(bool wait, long long usec_timeout=-1, long long* usec_timeout_remaining=NULL);
127 ** overloaded methods from t2n classes:
130 virtual void real_write(const std::string& data);
132 virtual bool fill_buffer(long long usec_timeout=-1,long long* usec_timeout_remaining=NULL);
137 AsyncIo::IOImplementationPtr m_real_connection;
138 T2NServerBaseWeakPtr m_server_weak_ptr;
142 }; // eo class T2NServerConnection
147 * @brief base server class for handling server ports for libt2n.
149 * Needs to be derived for the real type of connection (unix, IPv4, etc.).
151 * Does all necessary connection handling and realizes the abstract methods from
152 * the libt2n::server class.
155 : public libt2n::server
156 , virtual public SharedBase
159 virtual ~T2NServerBase();
164 ** overloaded methods from t2n classes:
167 virtual bool fill_buffer(long long usec_timeout=-1, long long* timeout_remaining=NULL);
171 boost::signal< void() > m_signal_client_got_new_data;
175 T2NServerBase( AsyncIo::ServerSocketBaseImplementationPtr server_port);
177 void newConnectionSlot(AsyncIo::IOImplementationPtr io_ptr);
179 void clientGotNewDataSlot();
182 ** overloaded methods from t2n classes:
185 virtual bool fill_connection_buffers(void);
190 AsyncIo::ServerSocketBaseImplementationPtr m_server_port;
191 bool m_new_data_available;
193 }; // eo T2NServerBase
196 typedef boost::shared_ptr< T2NServerBase > T2NServerBasePtr;
199 T2NServerBasePtr createT2NUnixServerPort(const std::string& path, int mode= 0600);
201 T2NClientConnectionPtr createT2NUnixClientConnection(const std::string& path);
204 } // eo namespace AsyncIo