- Code: Select all
template
class TorrentConnectionAcceptor : public SocketAcceptor
{
public:
TorrentConnectionAcceptor(ServerSocket &socket, SocketReactor &reactor)
: SocketAcceptor(socket, reactor),
mainSocket(socket),
mainReactor(reactor)
{
}
virtual ServiceHandler* createServiceHandler(StreamSocket& socket)
{
return new TorrentProtocolHandler(socket, mainReactor, &cache);
}
private:
ExpireCachecache;
ServerSocket &mainSocket;
SocketReactor &mainReactor;
};
The constructor in TorrentProtocolHandler.cpp:
- Code: Select all
TorrentProtocolHandler(StreamSocket& socket, SocketReactor& reactor, ExpireCache*cache);
In main.cpp when I call this:
- Code: Select all
TorrentConnectionAcceptoracceptor(svs, reactor);
I get the following compiler errors:
usr/local/include/Poco/Net/SocketAcceptor.h: In member function 'ServiceHandler* Poco::Net::SocketAcceptor
/usr/local/include/Poco/Net/SocketAcceptor.h:144: instantiated from 'void Poco::Net::SocketAcceptor
/usr/local/include/Poco/Net/SocketAcceptor.h:136: instantiated from 'void Poco::Net::SocketAcceptor
/usr/local/include/Poco/Net/SocketAcceptor.h:111: instantiated from 'Poco::Net::SocketAcceptor
/Users/Electic/Documents/Source Code/Torrent Rovers/Torrent Listener/TorrentConnectionAcceptor.h:10: instantiated from here
/usr/local/include/Poco/Net/SocketAcceptor.h:153: error: no matching function for call to 'TorrentProtocolHandler::TorrentProtocolHandler(Poco::Net::StreamSocket&, Poco::Net::SocketReactor&)'
/Users/Electic/Documents/Source Code/Torrent Rovers/Torrent Listener/TorrentProtocolHandler.h:18: note: candidates are: TorrentProtocolHandler::TorrentProtocolHandler(Poco::Net::StreamSocket&, Poco::Net::SocketReactor&, Poco::ExpireCache
/Users/Electic/Documents/Source Code/Torrent Rovers/Torrent Listener/TorrentProtocolHandler.h:16: note: TorrentProtocolHandler::TorrentProtocolHandler(const TorrentProtocolHandler&)
So for some reason, the base class is not being overridden because the compiler still wants to go here and check this function in SocketAcceptor.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);
}
Does any one have an example of successfully overriding this class or see what I am doing wrong? Is the SocketReactor example a good implementation idea for large amount of incoming connections or is a TCPServer a better choice and is there an example of the TCPServer with a reactor attached?





