Overview
Features
Download
Documentation
Community
Add-Ons & Services

Self implemented SocketAcceptor don't works!!

Please post support and help requests here.

Self implemented SocketAcceptor don't works!!

Postby flomll » 24 May 2012, 15:11

Hy, I would like to implement my own MySocketAcceptor class. The problem is, that won't work. I saw the entry from http://pocoproject.org/forum/viewtopic.php?t=3824. But I can't build the framework with split SocketAcceptor class.

Has anyone a run-able self implemented (derived) SocketAcceptor class?

Code: Select all
template <class ServiceHandler>
class CSSocketAcceptor : public Poco::Net::SocketAcceptor<ServiceHandler>
{
   Json::Rpc::Handler _handler;
public:
   virtual ~CSSocketAcceptor();

   virtual ServiceHandler* createServiceHandler(Poco::Net::StreamSocket& socket);
};


If I do this I get the following error:
Code: Select all
In file included from ../CSSocketAcceptor.h:11:0,
                 from ../CSSocketAcceptor.cpp:8:
/usr/local/lib/poco-1.4.3p1-all/include/Poco/Net/SocketAcceptor.h: In member function ‘virtual void Poco::Net::SocketAcceptor<ServiceHandler>::registerAcceptor(Poco::Net::SocketReactor&)’:
/usr/local/lib/poco-1.4.3p1-all/include/Poco/Net/SocketAcceptor.h:123:12: error: invalid use of incomplete type ‘struct Poco::Net::SocketReactor’
/usr/local/lib/poco-1.4.3p1-all/include/Poco/Net/SocketNotification.h:52:7: error: forward declaration of ‘struct Poco::Net::SocketReactor’
/usr/local/lib/poco-1.4.3p1-all/include/Poco/Net/SocketAcceptor.h: In member function ‘virtual void Poco::Net::SocketAcceptor<ServiceHandler>::unregisterAcceptor()’:
/usr/local/lib/poco-1.4.3p1-all/include/Poco/Net/SocketAcceptor.h:136:13: error: invalid use of incomplete type ‘struct Poco::Net::SocketReactor’
/usr/local/lib/poco-1.4.3p1-all/include/Poco/Net/SocketNotification.h:52:7: error: forward declaration of ‘struct Poco::Net::SocketReactor’
make: *** [CSSocketAcceptor.o] Error 1


Can anyone help me?
flomll
 
Posts: 28
Joined: 18 May 2012, 08:58
Location: Austria

Re: Self implemented SocketAcceptor don't works!!

Postby flomll » 24 May 2012, 15:37

What's going wrong at the marked lines? The copied the code from the SocketAcceptor.h into new SocketAcceptor.cpp file and modified some function declarations at the .cpp file which are need for template classes.

Code: Select all
template <class ServiceHandler>
void SocketAcceptor<ServiceHandler>::registerAcceptor(SocketReactor& reactor)
   /// Registers the SocketAcceptor with a SocketReactor.
   ///
   /// A subclass can override this and, for example, also register
   /// an event handler for a timeout event.
   ///
   /// The overriding method must call the baseclass implementation first.
{
   _pReactor = &reactor;
        // Error at the following line:
   //_pReactor->addEventHandler(_socket, Poco::Observer<SocketAcceptor, ReadableNotification>(*this, &SocketAcceptor::onAccept));
}

template <class ServiceHandler>
void SocketAcceptor<ServiceHandler>::unregisterAcceptor()
   /// Unregisters the SocketAcceptor.
   ///
   /// A subclass can override this and, for example, also unregister
   /// its event handler for a timeout event.
   ///
   /// The overriding method must call the baseclass implementation first.
{
   if (_pReactor)
   {
                // Error at the following line:
      //_pReactor->removeEventHandler(_socket, Poco::Observer<SocketAcceptor, ReadableNotification>(*this, &SocketAcceptor::onAccept));
   }
}

template <class ServiceHandler>
ServiceHandler* SocketAcceptor<ServiceHandler>::createServiceHandler(StreamSocket& socket)
   /// Create and initialize a new ServiceHandler instance.
   ///
   /// Subclasses can override this method.

   return new ServiceHandler(socket, *_pReactor);
}
flomll
 
Posts: 28
Joined: 18 May 2012, 08:58
Location: Austria

Re: Self implemented SocketAcceptor don't works!!

Postby flomll » 15 Nov 2012, 08:45

I paused this project for a long time. Now I am back and have a solution for this problem. I will test it and post the subclass later! :lol:
flomll
 
Posts: 28
Joined: 18 May 2012, 08:58
Location: Austria


Return to Support

Who is online

Users browsing this forum: No registered users and 3 guests

cron