Overview
Features
Download
Documentation
Community
Add-Ons & Services

Unable to compile overloaded createServiceHandler

Please post support and help requests here.

Unable to compile overloaded createServiceHandler

Postby marlondean » 25 Jul 2012, 13:16

Hi everyone,

I just started using POCO for the networking library and I ran into an issue with compiling my code. I have a templated class, MySocketAcceptor that inherits from SocketAcceptor. I overload the createServiceHandler function with hopes of doing something in there, but I cannot compile it.

Code: Select all
template <class MyTemplate> class MySocketAcceptor : public SocketAcceptor<MySocket<MyTemplate>>
{
public:
   MySocketAcceptor (MyServerr<MyTemplate> & server, ServerSocket & socket, SocketReactor & reactor) : SocketAcceptor<MySocket<MyTemplate>>(socket, reactor), m_server(server), m_reactor(reactor)
   {
   }

protected:

   MySocket<MyTemplate> * createServiceHandler(StreamSocket & socket)
   {
      MySocket<MyTemplate> * conn = new MySocket<MyTemplate>(socket, m_reactor, m_server);
      m_server.RegisterClientConnection(conn);
      return conn;
   }

private:
   MyServer<MyTemplate> & m_server;
   SocketReactor & m_reactor;
};


When compiling this code, I get the following error : "error C2661: 'MySocket<MyTemplate>::MySocket' : no overloaded function takes 2 arguments c:\source\include\poco\net\socketacceptor.h 153". It refers to the following in socketaccpetor.h:

Code: Select all
virtual ServiceHandler* createServiceHandler(StreamSocket& socket)
      /// Create and initialize a new ServiceHandler instance.
      ///
      /// Subclasses can override this method.
   {
      return new ServiceHandler(socket, *_pReactor);
   }


Can anyone offer some guidance to a first time user? Any suggestions will be appreciated.
marlondean
 
Posts: 7
Joined: 25 Jul 2012, 12:58

Re: Unable to compile overloaded createServiceHandler

Postby marlondean » 26 Jul 2012, 11:48

The problem is that the MySocket<MyTemplate> class ctor expected 3 variables instead of the 2 as per ServiceHandler. The solution was to create a 'dummy ctor' for the MySocket class that only takes the expected parameters.
marlondean
 
Posts: 7
Joined: 25 Jul 2012, 12:58


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron