Library: Net
Package: TCPServer
Header: Poco/Net/TCPServerConnectionFactory.h
Description
A factory for TCPServerConnection objects.
The TCPServer class uses a TCPServerConnectionFactory to create a connection object for each new connection it accepts.
Subclasses must override the createConnection() method, which can refuse connections by returning nullptr. Some examples when an implementation may refuse new connections:
- number of connections exceeded a limit - a connection from unwanted client attempted - too many connection attempts in a short timespan - etc.
The TCPServerConnectionFactoryImpl template class can be used to automatically instantiate a TCPServerConnectionFactory for a given subclass of TCPServerConnection.
Inheritance
Known Derived Classes: HTTPServerConnectionFactory, TCPServerConnectionFactoryImpl
Member Summary
Member Functions: createConnection, isStopped, operator =, stop
Types Aliases
Ptr
using Ptr = Poco::SharedPtr < TCPServerConnectionFactory >;
Constructors
TCPServerConnectionFactory
TCPServerConnectionFactory(
const TCPServerConnectionFactory & param476
) = delete;
TCPServerConnectionFactory
TCPServerConnectionFactory(
TCPServerConnectionFactory && param478
) = delete;
TCPServerConnectionFactory
Creates the TCPServerConnectionFactory.
Destructor
~TCPServerConnectionFactory
virtual ~TCPServerConnectionFactory();
Destroys the TCPServerConnectionFactory.
Member Functions
createConnection
virtual TCPServerConnection * createConnection(
const StreamSocket & socket
) = 0;
Creates an instance of a subclass of TCPServerConnection, using the given StreamSocket. This function is allowed to return nullptr, in which case an accepted socket will be destroyed by the TCPServerDispatcher.
isStopped
bool isStopped() const;
Returns true if the factory was stopped, false otherwise.
operator =
TCPServerConnectionFactory & operator = (
const TCPServerConnectionFactory & param477
) = delete;
operator =
TCPServerConnectionFactory & operator = (
TCPServerConnectionFactory && param479
) = delete;
stop
void stop();
Stops the factory. Normally, this function is called by TCPServerDispatcher to indicate that the server is shutting down; the expected implementation behavior after this call is to return nullptr on all subsequent connection creation attempts.