NCBI C++ ToolKit
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
CServer Class Reference

Search Toolkit Book for CServer

CServer:: More...

#include <connect/server.hpp>

+ Inheritance diagram for CServer:
+ Collaboration diagram for CServer:

Public Member Functions

 CServer (void)
virtual ~CServer ()
void AddListener (IServer_ConnectionFactory *factory, unsigned short port)
 Register a listener. More...
bool RemoveListener (unsigned short port)
 Removes a listener. More...
void SetParameters (const SServer_Parameters &new_params)
void GetParameters (SServer_Parameters *params)
void StartListening (void)
 Start listening before the main loop. More...
void Run (void)
 Enter the main loop. More...
void SubmitRequest (const CRef< CStdRequest > &request)
 Submit request to be executed by the server thread pool. More...
void DeferConnectionProcessing (IServer_ConnectionBase *conn)
 Mark connection as deferred for processing, i.e. More...
void DeferConnectionProcessing (CSocket *sock)
void CloseConnection (CSocket *sock)
 Close connection. More...
void AddConnectionToPool (CServer_Connection *conn)
 Add externally created connection to the connection pool which server polls on. More...
void RemoveConnectionFromPool (CServer_Connection *conn)
 Remove externally created connection from pool. More...
void WakeUpPollCycle (void)
 Force poll cycle to make another iteration. More...
void SetCustomThreadSuffix (const string &suffix)
 Set custom suffix to use on all threads in the server's pool. More...
vector< unsigned short > GetListenerPorts (void)
 Provides a list of ports on which the server is listening. More...

Protected Member Functions

virtual void Init ()
 Initialize the server. More...
virtual void Exit ()
 Cleanup the server. More...
virtual void ProcessTimeout (void)
 Runs synchronously when no socket activity has occurred in a while (as determined by m_AcceptTimeout). More...
virtual bool ShutdownRequested (void)
 Runs synchronously between iterations. More...
- Protected Member Functions inherited from CConnIniter
 CConnIniter (void)

Private Member Functions

void x_DoRun (void)
CPoolOfThreads_ForServerGetThreadPool (void)

Private Attributes

string m_ThreadSuffix


class CNetCacheServer

Detailed Description


Thread-pool based server. On every event it allocates one of threads from pool to serve the event, thereby making possible to serve large number of concurrent connections efficiently. You need to subclass it only if you want to provide gentle shutdown ability (override ShutdownRequested) or process data in main thread on timeout (override ProcessTimeout and set parameter accept_timeout to non-zero value).

Definition at line 96 of file server.hpp.

The documentation for this class was generated from the following files:
Modified on Sat Apr 13 11:46:21 2024 by rev. 669887