Start implementing an fcgi minimalist prototype
authorEbersold Andre <aebersol@md2p7zxc.ad001.siemens.net>
Fri, 3 Jun 2022 15:05:56 +0000 (17:05 +0200)
committerEbersold Andre <aebersol@md2p7zxc.ad001.siemens.net>
Fri, 3 Jun 2022 15:05:56 +0000 (17:05 +0200)
aeb/fcgi/fcgi.h [new file with mode: 0644]

diff --git a/aeb/fcgi/fcgi.h b/aeb/fcgi/fcgi.h
new file mode 100644 (file)
index 0000000..8511368
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef __FCGI_H__
+#define __FCGI_H__
+
+namespace aeb {
+namespace fcgi {
+
+
+/**
+ *
+ */
+template <typename Descriptor,typename InternetProtocol>
+class acceptor : public basic_socket_acceptor<Descriptor,InternetProtocol>
+{
+  public:
+    typedef Descriptor socket_type;
+    acceptor(const ip::basic_endpoint<InternetProtocol> &e) :
+           basic_socket_acceptor<Descriptor,InternetProtcol>(e)
+   {
+      int val = 1;
+      m_socket.set_option(SO_REUSEADDR,val);
+   };
+    // Acceptor main entry
+    void on_accept()
+    {
+      endpoint_type tmp;
+      int len = tmp.size();
+      detail::socket_type s;
+      aeb::sys::error ec;
+      
+      s = aeb::net::accept<socklen_t>(this->m_descriptor,tmp.data(),&len,ec);
+      std::cout<<"fcgi::acceptor ("<<this->m_descriptor<<"):"<<" Error="<<ec.code()<<" socket="<<std::endl;
+      
+      if (s != aeb::net::detail::invalid_socket)
+      {
+             m_r = request_handler::ptr(new request_handler(s)) ;
+          m_r->add_ref(); //because request_handler will kill himself 
+      }   
+    };
+  protected:
+    request_handler::ptr m_r;    
+};
+
+
+
+}; // End fcgi
+}; // End aeb
+
+#endif