# Poco::Net

# class TCPServerDispatcher

Library: Net
Package: TCPServer
Header: Poco/Net/TCPServerDispatcher.h

## Description

A helper class for TCPServer that dispatches connections to server connection threads.

## Inheritance

Direct Base Classes: Poco::Runnable

All Base Classes: Poco::Runnable

## Member Summary

Member Functions: beginConnection, currentConnections, currentThreads, duplicate, endConnection, enqueue, maxConcurrentConnections, maxThreads, params, queuedConnections, refusedConnections, release, run, stop, totalConnections

Inherited Functions: run

## Constructors

### TCPServerDispatcher

TCPServerDispatcher(
TCPServerConnectionFactory::Ptr pFactory,
Poco::ThreadPool & threadPool,
TCPServerParams::Ptr pParams
);

Creates the TCPServerDispatcher.

The dispatcher takes ownership of the TCPServerParams object. If no TCPServerParams object is supplied, the TCPServerDispatcher creates one.

## Destructor

### ~TCPServerDispatcher

~TCPServerDispatcher();

Destroys the TCPServerDispatcher.

## Member Functions

### currentConnections

int currentConnections() const;

Returns the number of currently handled connections.

### currentThreads

int currentThreads() const;

Returns the number of currently used threads.

### duplicate

void duplicate();

Increments the object's reference count.

### enqueue

void enqueue(
const StreamSocket & socket
);

Queues the given socket connection.

### maxConcurrentConnections

int maxConcurrentConnections() const;

Returns the maximum number of concurrently handled connections.

### maxThreads

int maxThreads() const;

Returns the maximum number of threads available.

### params

const TCPServerParams & params() const;

Returns a const reference to the TCPServerParam object.

### queuedConnections

int queuedConnections() const;

Returns the number of queued connections.

### refusedConnections

int refusedConnections() const;

Returns the number of refused connections.

### release

void release();

Decrements the object's reference count and deletes the object if the count reaches zero.

### run

void run();

Runs the dispatcher.

See also: Poco::Runnable::run()

### stop

void stop();

Stops the dispatcher.

### totalConnections

Int64 totalConnections() const;

Returns the total number of handled connections.

### beginConnection

void beginConnection();

Updates the performance counters.

### endConnection

void endConnection();

Updates the performance counters.