/**
*
*/
-template <typename Descriptor,typename InternetProtocol>
+template <typename Descriptor,typename InternetProtocol,typename RequestHandler>
class acceptor : public basic_socket_acceptor<Descriptor,InternetProtocol>
{
public:
if (s != aeb::net::detail::invalid_socket)
{
- m_r = request_handler::ptr(new request_handler(s)) ;
+ m_r = RequestHandler::ptr(new RequestHandler(s)) ;
m_r->add_ref(); //because request_handler will kill himself
}
};
protected:
- request_handler::ptr m_r;
+ RequestHandler::ptr m_r;
};
--- /dev/null
+#ifndef __FCGI_H__
+#define __FCGI_H__
+
+namespace aeb {
+namespace fcgi {
+
+/**
+ * \brief The handler is reponsible to act as an interface between the
+ * socket and a request. There is one handler per socket. However, there can
+ * be multiple requests per socket.
+ * The handler is responsible to dispatch the read message to the right
+ * request handler. Hence this class is more a kind of fcgi message handler
+ * on top of which we will have the Request handler. :w
+ *
+ */
+
+class handler : public event_handler<detail::socket_type,ip::tcp>
+{
+ private:
+ int m_ref;
+ public:
+
+ typedef basic_socket_stream<ip::tcp> Stream;
+ /// aeb::ssl::stream<ip::tcp> ? or detail::socket_type
+ typedef basic_socket_stream<ip::tcp> SSLStream;
+
+ typedef aeb::intrusive_ptr<ws_handler> ptr;
+
+ inline void add_ref() {m_ref++;};
+
+ inline void release() {
+ if (--m_ref == 0) delete this;
+ };
+ bool available () const;
+
+ public:
+ handler(detail::socket_type s);
+
+ virtual ~handler() ;
+
+ virtual void onClose(unsigned short _code) ;
+
+ void on_write() ;
+
+ void on_read() ;
+
+ void on_accept();
+
+ void io_register();
+
+ void io_unregister();
+ // reuse handler with a new socket
+ void reuse(aeb::net::detail::socket_type s);
+
+ protected:
+ handler(const ws_handler &p) ;
+ // Should own an endpoint
+ long m_max_frame_size;
+};
+
+/**
+vim:et:sw=2:ts=2
+ */
+
+
+#endif /*WS_HANDLER_H*/
+}
+}
+
ip4_server.cpp\r
)\r
\r
+ ADD_EXECUTABLE(fcgi_hello\r
+ fcgi_helloworld.cpp\r
+ )\r
+\r
ADD_EXECUTABLE(intrusive_ptr\r
intrusive_ptr.cpp\r
)\r
--- /dev/null
+#if 0
+#include <windows.h>
+#include <winsock2.h>
+#endif
+
+#include <iostream>
+
+#include <aeb/net/ip/tcp.h>
+#include <aeb/net/ip/basic_endpoint.h>
+#include <aeb/net/socket_base.h>
+#include <aeb/net/io_dispatcher.h>
+#include <aeb/net/basic_socket_acceptor.h>
+#include <aeb/net/basic_socket_stream.h>
+#include <aeb/pointer/intrusive_ptr.h>
+#if defined(__MINGW32__) ||defined(_WIN32)
+#include <aeb/net/detail/winsock_init.h>
+#endif
+
+#include <aeb/fcgi/fcgi.h>
+#include <aeb/fcgi/fcgi_handler.h>
+
+using namespace aeb::net;
+typedef aeb::net::io_dispatcher<aeb::net::detail::socket_type,ip::tcp> io_service;
+typedef aeb::net::basic_socket<ip::tcp> tcp_socket;
+
+/**
+ * @brief main entry point. A simple example to use
+ * the fcgi implementation. Will use this test
+ * to verify the communication
+ *
+ *
+ */
+int main(int argc,char **argv)
+{
+
+ ip::basic_endpoint<ip::tcp> ep(ip::tcp::v4(),10224);
+
+ aeb::fcgi::acceptor a(ep);
+
+ a.listen();
+
+: io_service *io = aeb::singleton<io_service>::get_instance();
+
+ io->register_handler(2,&a);
+
+ io->run(false);
+}