A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/group__ThreadedServer.html below:

NCBI C++ ToolKit: Threaded Server

enum   EServerConnType {
  eInactiveSocket , eActiveSocket , eListener , ePreDeferredSocket ,
  eDeferredSocket , ePreClosedSocket , eClosedSocket
}   enum   EServIO_Event {
  eServIO_Open = 0x00 , eServIO_Read = 0x01 , eServIO_Write = 0x02 , eServIO_ReadWrite = 0x03 ,
  eServIO_ClientClose = 0x04 , eServIO_OurClose = 0x08 , eServIO_Inactivity = 0x10 , eServIO_Delete = 0x20 ,
  eServIO_Alarm = 0x40
}   Extended copy of the type EIO_Event allowing to distinguish between connection closing from client and from ourselves. More...
  enum   EOverflowReason { eOR_Unknown = 0 , eOR_ConnectionPoolFull , eOR_RequestQueueFull , eOR_UnpollableSocket }   Error codes for OnOverflow method in IServer_ConnectionHandler. More...
  enum   IServer_ConnectionHandler::EClosePeer { IServer_ConnectionHandler::eOurClose , IServer_ConnectionHandler::eClientClose }   Type of connection closing. More...
  enum   IServer_ConnectionFactory::EListenAction { IServer_ConnectionFactory::eLAFail = 0 , IServer_ConnectionFactory::eLAIgnore = 1 , IServer_ConnectionFactory::eLARetry = 2 }   What to do if the port is busy. More...
  enum   CServer_Exception::EErrCode { CServer_Exception::eBadParameters , CServer_Exception::eCouldntListen , CServer_Exception::ePoolOverflow }   enum   CThreadedServerException::EErrCode { CThreadedServerException::eBadParameters , CThreadedServerException::eCouldntListen }   std::string  g_ServerConnTypeToString (enum EServerConnType conn_type)   virtual  IServer_ConnectionBase::~IServer_ConnectionBase ()   virtual EIO_Event  IServer_ConnectionBase::GetEventsToPollFor (const CTime **) const   virtual CStdRequestIServer_ConnectionBase::CreateRequest (EServIO_Event event, CServer_ConnectionPool &connPool, const STimeout *timeout)=0   virtual bool  IServer_ConnectionBase::IsOpen (void)   virtual bool  IServer_ConnectionBase::IsReadyToProcess (void)   virtual void  IServer_ConnectionBase::OnTimeout (void)   virtual void  IServer_ConnectionBase::OnTimer (void)   virtual void  IServer_ConnectionBase::OnOverflow (EOverflowReason)   virtual void  IServer_ConnectionBase::Activate (void)   virtual void  IServer_ConnectionBase::Passivate (void)     CServer_Connection::CServer_Connection (IServer_ConnectionHandler *handler)   virtual EIO_Event  CServer_Connection::GetEventsToPollFor (const CTime **alarm_time) const   virtual CStdRequestCServer_Connection::CreateRequest (EServIO_Event event, CServer_ConnectionPool &connPool, const STimeout *timeout)   virtual void  CServer_Connection::OnTimeout (void)   virtual void  CServer_Connection::OnOverflow (EOverflowReason reason)   virtual bool  CServer_Connection::IsReadyToProcess (void)   virtual bool  CServer_Connection::IsOpen (void)   void  CServer_Connection::OnSocketEvent (EServIO_Event event)   virtual  CServer_Connection::~CServer_Connection ()     CServer_Listener::CServer_Listener (IServer_ConnectionFactory *factory, unsigned short port)   virtual CStdRequestCServer_Listener::CreateRequest (EServIO_Event event, CServer_ConnectionPool &connPool, const STimeout *timeout)   virtual void  CServer_Listener::Activate (void)   virtual void  CServer_Listener::Passivate (void)   unsigned short  CServer_Listener::GetPort (void) const   EServIO_Event  IOEventToServIOEvent (EIO_Event event)   Transform EIO_Event type to EServIO_Event. More...
    CServer::CServer (void)   virtual  CServer::~CServer ()   void  CServer::AddListener (IServer_ConnectionFactory *factory, unsigned short port)   Register a listener. More...
  bool  CServer::RemoveListener (unsigned short port)   Removes a listener. More...
  void  CServer::SetParameters (const SServer_Parameters &new_params)   void  CServer::GetParameters (SServer_Parameters *params)   void  CServer::StartListening (void)   Start listening before the main loop. More...
  void  CServer::Run (void)   Enter the main loop. More...
  void  CServer::SubmitRequest (const CRef< CStdRequest > &request)   Submit request to be executed by the server thread pool. More...
  void  CServer::DeferConnectionProcessing (IServer_ConnectionBase *conn)   Mark connection as deferred for processing, i.e. More...
  void  CServer::DeferConnectionProcessing (CSocket *sock)   void  CServer::CloseConnection (CSocket *sock)   Close connection. More...
  void  CServer::AddConnectionToPool (CServer_Connection *conn)   Add externally created connection to the connection pool which server polls on. More...
  void  CServer::RemoveConnectionFromPool (CServer_Connection *conn)   Remove externally created connection from pool. More...
  void  CServer::WakeUpPollCycle (void)   Force poll cycle to make another iteration. More...
  void  CServer::SetCustomThreadSuffix (const string &suffix)   Set custom suffix to use on all threads in the server's pool. More...
  vector< unsigned short >  CServer::GetListenerPorts (void)   Provides a list of ports on which the server is listening. More...
  virtual void  CServer::Init ()   Initialize the server. More...
  virtual void  CServer::Exit ()   Cleanup the server. More...
  virtual void  CServer::ProcessTimeout (void)   Runs synchronously when no socket activity has occurred in a while (as determined by m_AcceptTimeout). More...
  virtual bool  CServer::ShutdownRequested (void)   Runs synchronously between iterations. More...
  void  CServer::x_DoRun (void)   CPoolOfThreads_ForServerCServer::GetThreadPool (void)   virtual  IServer_ConnectionHandler::~IServer_ConnectionHandler ()   virtual EIO_Event  IServer_ConnectionHandler::GetEventsToPollFor (const CTime **) const   Following three methods are guaranteed to be called NOT at the same time as On*, so if you implement them you should not guard the variables which they can use with mutexes. More...
  virtual const STimeoutIServer_ConnectionHandler::GetTimeout (void)   Returns the timeout for this connection. More...
  virtual bool  IServer_ConnectionHandler::IsOpen (void)   Returns connection handler's perception of whether we open or not. More...
  virtual bool  IServer_ConnectionHandler::IsReadyToProcess (void) const   Returns the handler's readiness to process input data or to write some output data. More...
  virtual void  IServer_ConnectionHandler::OnOpen (void)=0   Runs in response to an external event [asynchronous]. More...
  virtual void  IServer_ConnectionHandler::OnRead (void)=0   The client has just sent data. More...
  virtual void  IServer_ConnectionHandler::OnWrite (void)=0   The client is ready to receive data. More...
  virtual void  IServer_ConnectionHandler::OnClose (EClosePeer)   The connection has closed (with information on type of closing) More...
  virtual void  IServer_ConnectionHandler::OnTimeout (void)   Runs when a client has been idle for too long, prior to closing the connection [synchronous]. More...
  virtual void  IServer_ConnectionHandler::OnTimer (void)   This method is called at the moment in time specified earlier by the alarm_time parameter of the GetEventsToPollFor method [synchronous]. More...
  virtual void  IServer_ConnectionHandler::OnOverflow (EOverflowReason)   Runs when there are insufficient resources to queue a connection, prior to closing it. More...
  virtual void  IServer_ConnectionHandler::OnError (const string &)   Runs when a socket error is detected. More...
  CSocketIServer_ConnectionHandler::GetSocket (void)   Get underlying socket. More...
  void  IServer_ConnectionHandler::SetSocket (CSocket *socket)     IServer_MessageHandler::IServer_MessageHandler ()   virtual  IServer_MessageHandler::~IServer_MessageHandler ()   virtual void  IServer_MessageHandler::OnRead (void)   The client has just sent data. More...
  virtual int  IServer_MessageHandler::CheckMessage (BUF *buffer, const void *data, size_t size)=0   virtual void  IServer_MessageHandler::OnMessage (BUF buffer)=0   int  Server_CheckLineMessage (BUF *buffer, const void *data, size_t size, bool &seen_CR)     IServer_LineMessageHandler::IServer_LineMessageHandler ()   virtual int  IServer_LineMessageHandler::CheckMessage (BUF *buffer, const void *data, size_t size)   CNcbiIostreamIServer_StreamHandler::GetStream ()   virtual  IServer_ConnectionFactory::~IServer_ConnectionFactory ()   virtual IServer_ConnectionHandlerIServer_ConnectionFactory::Create (void)=0   virtual EListenAction  IServer_ConnectionFactory::OnFailure (unsigned short *)   Return desired action if the port, mentioned in AddListener is busy. More...
  virtual IServer_ConnectionHandlerCServer_ConnectionFactory< TServer_ConnectionHandler >::Create ()     SServer_Parameters::SServer_Parameters ()   Create structure with the default set of parameters. More...
  virtual const char *  CServer_Exception::GetErrCodeString (void) const override     CServer_Exception::NCBI_EXCEPTION_DEFAULT (CServer_Exception, CConnException)   virtual  IServer_Monitor::~IServer_Monitor ()   virtual bool  IServer_Monitor::IsActive ()=0   Check if monitoring is active. More...
  virtual void  IServer_Monitor::Send (const char *msg, size_t length)=0   Send message. More...
  virtual void  IServer_Monitor::Send (const string &str)=0   Send message. More...
    CServer_Monitor::CServer_Monitor ()   Server monitor. More...
  virtual  CServer_Monitor::~CServer_Monitor ()   void  CServer_Monitor::SetSocket (CSocket &socket)   Pass open socket for monitor output. More...
  bool  CServer_Monitor::IsMonitorActive ()   void  CServer_Monitor::SendMessage (const char *msg, size_t length)   void  CServer_Monitor::SendString (const string &str)     CServer_Monitor::CServer_Monitor (const CServer_Monitor &)   CServer_MonitorCServer_Monitor::operator= (const CServer_Monitor &)   virtual const char *  CThreadedServerException::GetErrCodeString (void) const override     CThreadedServerException::NCBI_EXCEPTION_DEFAULT (CThreadedServerException, CConnException)   NCBI_DEPRECATED_CLASS NCBI_XCONNECT_EXPORT  m_MaxThreads (10)   NCBI_DEPRECATED_CLASS NCBI_XCONNECT_EXPORT  m_QueueSize (20)   NCBI_DEPRECATED_CLASS NCBI_XCONNECT_EXPORT  m_SpawnThreshold (1)   NCBI_DEPRECATED_CLASS NCBI_XCONNECT_EXPORT  m_AcceptTimeout (kInfiniteTimeout)   NCBI_DEPRECATED_CLASS NCBI_XCONNECT_EXPORT  m_TemporarilyStopListening (false)   NCBI_DEPRECATED_CLASS NCBI_XCONNECT_EXPORT  m_Port (port)   virtual  ~CThreadedServer ()   void  Run (void)   Enter the main loop. More...
  void  StartListening (void)   Start listening immediately, or throw an exception if it is impossible to do so. More...
  virtual void  Process (SOCK sock)=0   Runs asynchronously (from a separate thread) for each request. More...
  unsigned short  GetPort () const   Get the listening port number back. More...
  virtual void  ProcessOverflow (SOCK sock)   Runs synchronously when request queue is full. More...
  virtual void  ProcessTimeout (void)   Runs synchronously when accept has timed out. More...
  virtual bool  ShutdownRequested (void)   Runs synchronously between iterations. More...
  virtual void  SetParams ()   Called at the beginning of Run, before creating thread pool. More...
    CServer_ConnectionPool::CServer_ConnectionPool (unsigned max_connections)     CServer_ConnectionPool::~CServer_ConnectionPool ()   void  CServer_ConnectionPool::SetMaxConnections (unsigned max_connections)   bool  CServer_ConnectionPool::Add (TConnBase *conn, EServerConnType type)   void  CServer_ConnectionPool::Remove (TConnBase *conn)   bool  CServer_ConnectionPool::RemoveListener (unsigned short port)   void  CServer_ConnectionPool::PingControlConnection (void)   void  CServer_ConnectionPool::SetConnType (TConnBase *conn, EServerConnType type)   Guard connection from out-of-order packet processing by pulling eActiveSocket's from poll vector Resets the expiration time as a bonus. More...
  void  CServer_ConnectionPool::SetAllActive (const vector< CSocketAPI::SPoll > &polls)   void  CServer_ConnectionPool::SetAllActive (const vector< IServer_ConnectionBase * > &conns)   void  CServer_ConnectionPool::CloseConnection (TConnBase *conn)   Close connection as if it was initiated by server (not by client). More...
  void  CServer_ConnectionPool::Erase (void)   Erase all connections. More...
  bool  CServer_ConnectionPool::GetPollAndTimerVec (vector< CSocketAPI::SPoll > &polls, vector< IServer_ConnectionBase * > &timer_requests, STimeout *timer_timeout, vector< IServer_ConnectionBase * > &revived_conns, vector< IServer_ConnectionBase * > &to_close_conns, vector< IServer_ConnectionBase * > &to_delete_conns)   void  CServer_ConnectionPool::StartListening (void)   void  CServer_ConnectionPool::StopListening (void)   vector< unsigned short >  CServer_ConnectionPool::GetListenerPorts (void)   Provides a list of ports on which the server is listening. More...
  void  CServer_ConnectionPool::x_UpdateExpiration (TConnBase *conn)   ◆ TConnBase ◆ TConnection ◆ TData ◆ TListener ◆ EClosePeer

Type of connection closing.

Enumerator eOurClose 

Connection closed by ourselves.

eClientClose 

Connection closed by other peer.

Definition at line 268 of file server.hpp.

◆ EErrCode [1/2] Enumerator eBadParameters 

Out-of-range parameters given.

eCouldntListen 

Unable to bind listening port.

ePoolOverflow 

Connection pool overflowed.

Definition at line 467 of file server.hpp.

◆ EErrCode [2/2] Enumerator eBadParameters 

Out-of-range parameters given.

eCouldntListen 

Unable to bind listening port.

Definition at line 55 of file threaded_server.hpp.

◆ EListenAction

What to do if the port is busy.

Enumerator eLAFail  eLAIgnore  eLARetry 

Definition at line 391 of file server.hpp.

◆ EOverflowReason

Error codes for OnOverflow method in IServer_ConnectionHandler.

Enumerator eOR_Unknown  eOR_ConnectionPoolFull  eOR_RequestQueueFull  eOR_UnpollableSocket 

Definition at line 209 of file server.hpp.

◆ EServerConnType Enumerator eInactiveSocket  eActiveSocket  eListener  ePreDeferredSocket  eDeferredSocket  ePreClosedSocket  eClosedSocket 

Definition at line 49 of file server_connection.hpp.

◆ EServIO_Event

Extended copy of the type EIO_Event allowing to distinguish between connection closing from client and from ourselves.

Enumerator eServIO_Open  eServIO_Read  eServIO_Write  eServIO_ReadWrite 

eIO_Read | eIO_Write

eServIO_ClientClose  eServIO_OurClose  eServIO_Inactivity  eServIO_Delete  eServIO_Alarm 

Definition at line 61 of file server.hpp.

◆ Activate() [1/2] virtual void IServer_ConnectionBase::Activate ( void  ) inlinevirtual ◆ Activate() [2/2] virtual void CServer_Listener::Activate ( void  ) inlinevirtual ◆ Add()

Definition at line 99 of file connection_pool.cpp.

References abort(), conn, eListener, set< Key, Compare >::end(), set< Key, Compare >::find(), set< Key, Compare >::insert(), CServer_ConnectionPool::m_Data, CServer_ConnectionPool::m_ListeningStarted, CServer_ConnectionPool::m_MaxConnections, CServer_ConnectionPool::m_Mutex, CServer_ConnectionPool::PingControlConnection(), set< Key, Compare >::size(), type, and CServer_ConnectionPool::x_UpdateExpiration().

Referenced by CServer::AddConnectionToPool(), CServer::AddListener(), and CAcceptRequest::x_DoProcess().

◆ AddConnectionToPool()

Add externally created connection to the connection pool which server polls on.

Throws exception if pool is full. NOTE: events to this connection can come theoretically even NOTE: if connection gets some error or its peer closes it then conn object will be deleted after processing OnClose event. If you don't want that you have to call RemoveConnectionFromPool while handling OnClose.

Definition at line 846 of file server.cpp.

References CServer_ConnectionPool::Add(), conn, eInactiveSocket, CServer::m_ConnectionPool, and NCBI_THROW.

◆ AddListener() ◆ CheckMessage() [1/2] virtual int IServer_LineMessageHandler::CheckMessage ( BUFbuffer, const void *  data, size_t  size  ) inlinevirtual ◆ CheckMessage() [2/2] virtual int IServer_MessageHandler::CheckMessage ( BUFbuffer, const void *  data, size_t  size  ) pure virtual ◆ CloseConnection() [1/2] void CServer::CloseConnection ( CSocketsock )

Close connection.

Method should be called only when closing is initiated by server itself, because it will generate then event eServIO_OurClose.

See also
EServIO_Event

Definition at line 664 of file server.cpp.

References CServer_ConnectionPool::CloseConnection(), and CServer::m_ConnectionPool.

Referenced by CNetScheduleHandler::OnMessage(), CNetStorageHandler::OnRead(), CNetScheduleHandler::x_HandleSocketErrorOnResponse(), CNetScheduleHandler::x_OnCmdParserError(), CNetStorageHandler::x_OnMessage(), CNetStorageHandler::x_OnSocketWriteError(), CNetScheduleHandler::x_PrepareWriteBuffer(), CNetScheduleHandler::x_ProcessMsgAuth(), CNetScheduleHandler::x_ProcessMsgQueue(), CNetScheduleHandler::x_ProcessQuitSession(), CNetStorageHandler::x_ReadRawData(), and CNetScheduleHandler::x_WriteMessage().

◆ CloseConnection() [2/2] void CServer_ConnectionPool::CloseConnection ( TConnBaseconn )

Close connection as if it was initiated by server (not by client).

Definition at line 212 of file connection_pool.cpp.

References CSocket::Abort(), conn, Critical(), eActiveSocket, ePreClosedSocket, ePreDeferredSocket, ERR_POST, eServIO_OurClose, g_ServerConnTypeToString(), and CServer_Connection::OnSocketEvent().

Referenced by CServer::CloseConnection(), and CServerConnectionRequest::x_Process().

◆ Create() [1/2]

template<class TServer_ConnectionHandler >

◆ Create() [2/2] ◆ CreateRequest() [1/3] ◆ CreateRequest() [2/3] ◆ CreateRequest() [3/3] ◆ CServer() CServer::CServer ( void  ) ◆ CServer_Connection() ◆ CServer_ConnectionPool() CServer_ConnectionPool::CServer_ConnectionPool ( unsigned  max_connections )

Definition at line 58 of file connection_pool.cpp.

◆ CServer_Listener() ◆ CServer_Monitor() [1/2] CServer_Monitor::CServer_Monitor ( ) ◆ CServer_Monitor() [2/2] ◆ DeferConnectionProcessing() [1/2] void CServer::DeferConnectionProcessing ( CSocketsock ) ◆ DeferConnectionProcessing() [2/2] ◆ Erase() void CServer_ConnectionPool::Erase ( void  ) ◆ Exit() virtual void CServer::Exit ( void  ) inlineprotectedvirtual

Cleanup the server.

Called by Run method after poll cycle when all processing threads are stopped, but before releasing listening ports. Here you're still guaranteed that another instance running on the same set of ports will fail at StartListening point.

Reimplemented in CNetStorageServer, and CNetScheduleServer.

Definition at line 181 of file server.hpp.

Referenced by CServer::Run().

◆ g_ServerConnTypeToString() ◆ GetErrCodeString() [1/2] const char * CServer_Exception::GetErrCodeString ( void  ) const overridevirtual ◆ GetErrCodeString() [2/2] const char * CThreadedServerException::GetErrCodeString ( void  ) const overridevirtual ◆ GetEventsToPollFor() [1/3] ◆ GetEventsToPollFor() [2/3]

Following three methods are guaranteed to be called NOT at the same time as On*, so if you implement them you should not guard the variables which they can use with mutexes.

Parameters
alarm_time Set this parameter to a pointer to a CTime object to recieve an OnTimer event at the moment in time specified by this object.
Returns
Returns the set of events for which Poll should check.

Reimplemented in CNetStorageHandler.

Definition at line 239 of file server.hpp.

References eIO_Read.

◆ GetEventsToPollFor() [3/3] ◆ GetListenerPorts() [1/2] vector< unsigned short > CServer::GetListenerPorts ( void  ) ◆ GetListenerPorts() [2/2] vector< unsigned short > CServer_ConnectionPool::GetListenerPorts ( void  ) ◆ GetParameters() ◆ GetPollAndTimerVec()

Definition at line 232 of file connection_pool.cpp.

References _ASSERT, CTime::DiffTimeSpan(), eActiveSocket, eClosedSocket, eDeferredSocket, CTime::eEmpty, eInactiveSocket, eIO_Read, eListener, set< Key, Compare >::erase(), ERASE_ITERATE, IServer_ConnectionBase::expiration, CTimeSpan::GetCompleteSeconds(), IServer_ConnectionBase::GetEventsToPollFor(), GetFastLocalTime(), CTimeSpan::GetNanoSecondsAfterSecond(), CServer_Listener::GetPort(), IServer_ConnectionBase::IsOpen(), IServer_ConnectionBase::IsReadyToProcess(), CFastMutex::Lock(), CServer_ConnectionPool::m_ControlTrigger, CServer_ConnectionPool::m_Data, CServer_ConnectionPool::m_ListenerPortsToStop, CServer_ConnectionPool::m_Mutex, NULL, CGuard< Resource, Lock, Unlock, ReportExceptions >::Release(), STimeoutTag::sec, IServer_ConnectionBase::type, IServer_ConnectionBase::type_lock, CFastMutex::Unlock(), and STimeoutTag::usec.

Referenced by CServer::x_DoRun().

◆ GetPort() [1/2] unsigned short GetPort ( void  ) const

Get the listening port number back.

Definition at line 107 of file threaded_server.hpp.

References m_Port.

Referenced by CSeqGraphicPane::AdjustViewPort(), CSeqGraphicPane::AdjustViewPortHeightToImage(), CGlWidgetDemo::CGlWidgetDemo(), CNetScheduleNotificationHandler::CmdAppendTimeoutGroupAndClientInfo(), GetPeerIpAndPort(), CHitMatrixPane::OnSize(), CHitMatrixPane::RenderVectorGraphics(), CNetScheduleNotificationHandler::RequestJobWatching(), CSeqGraphicPane::SetHorizontal(), CNetScheduleNotificationHandler::SubmitJob(), CHitMatrixPane::Update(), CSeqGraphicPane::x_Render(), and CHitMatrixPane::x_RenderContent().

◆ GetPort() [2/2] unsigned short CServer_Listener::GetPort ( void  ) const inline ◆ GetSocket() CSocket& IServer_ConnectionHandler::GetSocket ( void  ) inline

Get underlying socket.

Definition at line 294 of file server.hpp.

References IServer_ConnectionHandler::m_Socket.

Referenced by CRelocateCallback::Callback(), CNetScheduleHandler::OnClose(), CNetStorageHandler::OnClose(), CBDBEnvKeeperConnectionHandler::OnMessage(), CNetScheduleHandler::OnMessage(), CWNCTConnectionHandler::OnMessage(), CBDBEnvKeeperConnectionHandler::OnOpen(), CNetScheduleHandler::OnOpen(), CNetStorageHandler::OnOpen(), CWNCTConnectionHandler::OnOpen(), IServer_MessageHandler::OnRead(), CNetStorageHandler::OnRead(), CNetScheduleHandler::x_CreateConnContext(), CNetStorageHandler::x_CreateConnContext(), CNetScheduleHandler::x_GetPeerAddress(), CNetStorageHandler::x_GetPeerAddress(), CNetScheduleHandler::x_HandleSocketErrorOnResponse(), CNetScheduleHandler::x_OnCmdParserError(), CNetStorageHandler::x_OnMessage(), CNetStorageHandler::x_OnSocketWriteError(), CNetScheduleHandler::x_PrepareWriteBuffer(), CNetScheduleHandler::x_PrintCmdRequestStart(), CNetStorageHandler::x_PrintMessageRequestStart(), CNetScheduleHandler::x_ProcessMsgAuth(), CNetScheduleHandler::x_ProcessMsgBatchJob(), CNetScheduleHandler::x_ProcessMsgQueue(), CNetScheduleHandler::x_ProcessMsgRequest(), CNetScheduleHandler::x_ProcessQuitSession(), CWNCTConnectionHandler::x_ProcessRequest(), CNetScheduleHandler::x_ProcessStatistics(), CNetStorageHandler::x_ReadRawData(), CNetStorageHandler::x_SendOutputBuffer(), CNetStorageHandler::x_SendOverUTTP(), CNetScheduleHandler::x_SetQuickAcknowledge(), CNetStorageHandler::x_SetQuickAcknowledge(), and CNetScheduleHandler::x_WriteMessage().

◆ GetStream() ◆ GetThreadPool() ◆ GetTimeout() virtual const STimeout* IServer_ConnectionHandler::GetTimeout ( void  ) inlinevirtual ◆ Init() virtual void CServer::Init ( void  ) inlineprotectedvirtual ◆ IOEventToServIOEvent() ◆ IsActive() [1/2] bool CServer_Monitor::IsActive ( ) virtual ◆ IsActive() [2/2] virtual bool IServer_Monitor::IsActive ( ) pure virtual ◆ IServer_LineMessageHandler() IServer_LineMessageHandler::IServer_LineMessageHandler ( ) inline

Definition at line 349 of file server.hpp.

◆ IServer_MessageHandler() IServer_MessageHandler::IServer_MessageHandler ( ) inline

Definition at line 315 of file server.hpp.

◆ IsMonitorActive() bool CServer_Monitor::IsMonitorActive ( ) ◆ IsOpen() [1/3] virtual bool IServer_ConnectionBase::IsOpen ( void  ) inlinevirtual ◆ IsOpen() [2/3] bool CServer_Connection::IsOpen ( void  ) virtual ◆ IsOpen() [3/3] virtual bool IServer_ConnectionHandler::IsOpen ( void  ) inlinevirtual

Returns connection handler's perception of whether we open or not.

It is unsafe to just close underlying socket because of the race, emerging due to the fact that the socket can linger for a while.

Definition at line 247 of file server.hpp.

◆ IsReadyToProcess() [1/3] virtual bool IServer_ConnectionBase::IsReadyToProcess ( void  ) inlinevirtual ◆ IsReadyToProcess() [2/3] virtual bool CServer_Connection::IsReadyToProcess ( void  ) inlinevirtual ◆ IsReadyToProcess() [3/3] virtual bool IServer_ConnectionHandler::IsReadyToProcess ( void  ) const inlinevirtual

Returns the handler's readiness to process input data or to write some output data.

OnRead() and OnWrite() are not called unless this method return true.

Definition at line 252 of file server.hpp.

◆ m_AcceptTimeout() ◆ m_MaxThreads() ◆ m_Port() ◆ m_QueueSize() ◆ m_SpawnThreshold() ◆ m_TemporarilyStopListening() ◆ NCBI_EXCEPTION_DEFAULT() [1/2] ◆ NCBI_EXCEPTION_DEFAULT() [2/2] ◆ OnClose() virtual void IServer_ConnectionHandler::OnClose ( EClosePeer  ) inlinevirtual ◆ OnError() virtual void IServer_ConnectionHandler::OnError ( const string &  ) inlinevirtual ◆ OnFailure() virtual EListenAction IServer_ConnectionFactory::OnFailure ( unsigned short *  ) inlinevirtual ◆ OnMessage() virtual void IServer_MessageHandler::OnMessage ( BUF  buffer ) pure virtual ◆ OnOpen() virtual void IServer_ConnectionHandler::OnOpen ( void  ) pure virtual ◆ OnOverflow() [1/3] ◆ OnOverflow() [2/3] ◆ OnOverflow() [3/3]

Runs when there are insufficient resources to queue a connection, prior to closing it.

Provides a reason why the connection is being close, which can be reported back to the client.

Reimplemented in CNetStorageHandler, and CNetScheduleHandler.

Definition at line 288 of file server.hpp.

◆ OnRead() [1/2] void IServer_MessageHandler::OnRead ( void  ) virtual

The client has just sent data.

Implements IServer_ConnectionHandler.

Definition at line 54 of file server.cpp.

References IServer_MessageHandler::CheckMessage(), conn, eActiveSocket, IServer_ConnectionHandler::eClientClose, eIO_Success, eIO_Timeout, CSocket::GetPeerAddress(), IServer_ConnectionHandler::GetSocket(), int, IO_StatusStr(), IServer_MessageHandler::m_Buffer, NStr::NumericToString(), IServer_ConnectionHandler::OnClose(), IServer_ConnectionHandler::OnError(), IServer_MessageHandler::OnMessage(), IServer_ConnectionHandler::OnTimeout(), CSocket::Read(), read_buf(), and string.

◆ OnRead() [2/2] virtual void IServer_ConnectionHandler::OnRead ( void  ) pure virtual ◆ OnSocketEvent()

Definition at line 552 of file server.cpp.

References IServer_ConnectionHandler::eClientClose, IServer_ConnectionHandler::eOurClose, eServIO_Alarm, eServIO_ClientClose, eServIO_Delete, eServIO_Inactivity, eServIO_Open, eServIO_OurClose, eServIO_Read, eServIO_Write, CServer_Connection::m_Handler, CServer_Connection::m_Open, and CServer_Connection::OnTimeout().

Referenced by CServer_ConnectionPool::CloseConnection(), CAcceptRequest::x_DoProcess(), and CServerConnectionRequest::x_Process().

◆ OnTimeout() [1/3] virtual void IServer_ConnectionBase::OnTimeout ( void  ) inlinevirtual ◆ OnTimeout() [2/3] virtual void CServer_Connection::OnTimeout ( void  ) inlinevirtual ◆ OnTimeout() [3/3] virtual void IServer_ConnectionHandler::OnTimeout ( void  ) inlinevirtual ◆ OnTimer() [1/2] virtual void IServer_ConnectionBase::OnTimer ( void  ) inlinevirtual

Definition at line 75 of file server_connection.hpp.

◆ OnTimer() [2/2] virtual void IServer_ConnectionHandler::OnTimer ( void  ) inlinevirtual

This method is called at the moment in time specified earlier by the alarm_time parameter of the GetEventsToPollFor method [synchronous].

Definition at line 282 of file server.hpp.

◆ OnWrite() virtual void IServer_ConnectionHandler::OnWrite ( void  ) pure virtual ◆ operator=() ◆ Passivate() [1/2] virtual void IServer_ConnectionBase::Passivate ( void  ) inlinevirtual ◆ Passivate() [2/2] virtual void CServer_Listener::Passivate ( void  ) inlinevirtual ◆ PingControlConnection() void CServer_ConnectionPool::PingControlConnection ( void  ) ◆ Process() virtual void Process ( SOCK  sock ) pure virtual ◆ ProcessOverflow() virtual void ProcessOverflow ( SOCK  sock ) protectedvirtual

Runs synchronously when request queue is full.

Implementor must take care of closing socket when done.

Definition at line 112 of file threaded_server.hpp.

References SOCK_Close().

◆ ProcessTimeout() [1/2] virtual void CServer::ProcessTimeout ( void  ) inlineprotectedvirtual ◆ ProcessTimeout() [2/2] virtual void ProcessTimeout ( void  ) protectedvirtual ◆ Remove() void CServer_ConnectionPool::Remove ( TConnBaseconn ) ◆ RemoveConnectionFromPool() ◆ RemoveListener() [1/2] bool CServer::RemoveListener ( unsigned short  port ) ◆ RemoveListener() [2/2] bool CServer_ConnectionPool::RemoveListener ( unsigned short  port )

Definition at line 134 of file connection_pool.cpp.

References eListener, ERR_POST, CServer_Listener::GetPort(), ITERATE, CFastMutex::Lock(), CServer_ConnectionPool::m_Data, CServer_ConnectionPool::m_ListenerPortsToStop, CServer_ConnectionPool::m_Mutex, CServer_ConnectionPool::PingControlConnection(), IServer_ConnectionBase::type, IServer_ConnectionBase::type_lock, CFastMutex::Unlock(), and Warning().

Referenced by CServer::RemoveListener().

◆ Run() [1/2] void CServer::Run ( void  )

Enter the main loop.

Definition at line 793 of file server.cpp.

References CServer_ConnectionPool::Erase(), ERR_POST, CServer::Exit(), CPoolOfThreads_ForServer::KillAllThreads(), CServer::m_ConnectionPool, CServer::m_Parameters, CServer::m_ThreadPool, CServer::m_ThreadSuffix, SServer_Parameters::max_threads, s_ServerCatchExceptions, CServer::StartListening(), CServer_ConnectionPool::StopListening(), and CServer::x_DoRun().

Referenced by CGridControlThread::Main(), and CBDBEnvKeeperApp::Run().

◆ Run() [2/2] ◆ Send() [1/4] void CServer_Monitor::Send ( const char *  msg, size_t  length  ) virtual ◆ Send() [2/4] virtual void IServer_Monitor::Send ( const char *  msg, size_t  length  ) pure virtual ◆ Send() [3/4] ◆ Send() [4/4] virtual void IServer_Monitor::Send ( const stringstr ) pure virtual ◆ SendMessage() void CServer_Monitor::SendMessage ( const char *  msg, size_t  length  ) ◆ SendString() void CServer_Monitor::SendString ( const stringstr ) ◆ Server_CheckLineMessage() int Server_CheckLineMessage ( BUFbuffer, const void *  data, size_t  size, boolseen_CR  ) ◆ SetAllActive() [1/2] ◆ SetAllActive() [2/2] ◆ SetConnType()

Guard connection from out-of-order packet processing by pulling eActiveSocket's from poll vector Resets the expiration time as a bonus.

Definition at line 178 of file connection_pool.cpp.

References conn, eClosedSocket, eDeferredSocket, eInactiveSocket, ePreClosedSocket, ePreDeferredSocket, CServer_ConnectionPool::PingControlConnection(), type, and CServer_ConnectionPool::x_UpdateExpiration().

Referenced by CServerConnectionRequest::Cancel(), CServer::DeferConnectionProcessing(), CServerConnectionRequest::Process(), and CAcceptRequest::x_DoProcess().

◆ SetCustomThreadSuffix() void CServer::SetCustomThreadSuffix ( const stringsuffix ) inline

Set custom suffix to use on all threads in the server's pool.

Value can be set only before call to Run(), any change of the value after call to Run() will be ignored.

Definition at line 161 of file server.hpp.

References CServer::m_ThreadSuffix.

◆ SetMaxConnections() void CServer_ConnectionPool::SetMaxConnections ( unsigned  max_connections ) inline ◆ SetParameters() ◆ SetParams() virtual void SetParams ( ) protectedvirtual ◆ SetSocket() [1/2] void CServer_Monitor::SetSocket ( CSocketsocket )

Pass open socket for monitor output.

The original socket is empty afterwards, ownership is handled by monitor. It activates the monitor.

Definition at line 53 of file server_monitor.cpp.

References eCopyTimeoutsFromSOCK, eCopyTimeoutsToSOCK, eNoOwnership, eTakeOwnership, CSocket::GetSOCK(), CServer_Monitor::m_Lock, CServer_Monitor::m_Sock, CSocket::Reset(), CServer_Monitor::SendString(), and CSocket::SetOwnership().

◆ SetSocket() [2/2] void IServer_ConnectionHandler::SetSocket ( CSocketsocket ) inline ◆ ShutdownRequested() [1/2] virtual bool CServer::ShutdownRequested ( void  ) inlineprotectedvirtual ◆ ShutdownRequested() [2/2] virtual bool ShutdownRequested ( void  ) protectedvirtual ◆ SServer_Parameters() SServer_Parameters::SServer_Parameters ( )

Create structure with the default set of parameters.

Definition at line 878 of file server.cpp.

◆ StartListening() [1/3] void CServer::StartListening ( void  ) ◆ StartListening() [2/3] void StartListening ( void  )

Start listening immediately, or throw an exception if it is impossible to do so.

(Does nothing if *this* object is already listening on the port.) Calling StartListening() before Run() will permit detecting port-in-use problems before the last minute. (On the other hand, clients that attempt to connect in the interim will get no response until the main loop actually starts.)

◆ StartListening() [3/3] void CServer_ConnectionPool::StartListening ( void  ) ◆ StopListening() void CServer_ConnectionPool::StopListening ( void  ) ◆ SubmitRequest() ◆ WakeUpPollCycle() void CServer::WakeUpPollCycle ( void  ) ◆ x_DoRun() void CServer::x_DoRun ( void  ) private

Definition at line 677 of file server.cpp.

References _ASSERT, SServer_Parameters::accept_timeout, CPoolOfThreads_ForServer::AcceptRequest(), count, IServer_ConnectionBase::CreateRequest(), Critical(), eIO_Success, eIO_Timeout, ERR_POST_X, eServIO_Alarm, eServIO_Delete, eServIO_Inactivity, IServer_ConnectionBase::GetEventsToPollFor(), CServer_ConnectionPool::GetPollAndTimerVec(), SServer_Parameters::idle_timeout, CServer::Init(), NStr::IntToString(), IO_StatusStr(), IOEventToServIOEvent(), ITERATE, kDefaultTimeout, kInfiniteTimeout, CServer::m_ConnectionPool, CServer::m_Parameters, CServer::m_ThreadPool, SServer_Parameters::max_threads, NULL, CSocketAPI::Poll(), CServer::ProcessTimeout(), CTrigger::Reset(), CServer_ConnectionPool::SetAllActive(), CServer::ShutdownRequested(), CPoolOfThreads_ForServer::Spawn(), and NStr::UIntToString().

Referenced by CServer::Run().

◆ x_UpdateExpiration() void CServer_ConnectionPool::x_UpdateExpiration ( TConnBaseconn ) private ◆ ~CServer() ◆ ~CServer_Connection() CServer_Connection::~CServer_Connection ( ) virtual ◆ ~CServer_ConnectionPool() CServer_ConnectionPool::~CServer_ConnectionPool ( ) ◆ ~CServer_Monitor() CServer_Monitor::~CServer_Monitor ( ) virtual ◆ ~CThreadedServer() ◆ ~IServer_ConnectionBase() virtual IServer_ConnectionBase::~IServer_ConnectionBase ( ) inlinevirtual

Definition at line 66 of file server_connection.hpp.

◆ ~IServer_ConnectionFactory() virtual IServer_ConnectionFactory::~IServer_ConnectionFactory ( ) inlinevirtual

Definition at line 396 of file server.hpp.

◆ ~IServer_ConnectionHandler() virtual IServer_ConnectionHandler::~IServer_ConnectionHandler ( ) inlinevirtual

Definition at line 228 of file server.hpp.

◆ ~IServer_MessageHandler() virtual IServer_MessageHandler::~IServer_MessageHandler ( ) inlinevirtual ◆ ~IServer_Monitor() virtual IServer_Monitor::~IServer_Monitor ( ) inlinevirtual

Definition at line 50 of file server_monitor.hpp.

◆ accept_timeout ◆ CThreadedServer

CThreadedServer - abstract class for network servers using thread pools.

This code maintains a pool of threads (initially m_InitThreads, but potentially as many as m_MaxThreads) to deal with incoming connections; each connection gets assigned to one of the worker threads, allowing the server to handle multiple requests in parallel while still checking for new requests.

You must define Process() to indicate what to do with each incoming connection; .../src/connect/test_threaded_server.cpp illustrates how you might do this.

Deprecated:
Use CServer instead.

Definition at line 77 of file threaded_server.hpp.

◆ expiration CTime IServer_ConnectionBase::expiration private ◆ idle_timeout

For how long to keep inactive non-listening sockets open (default: 10 minutes)

Definition at line 443 of file server.hpp.

Referenced by CServer::x_DoRun().

◆ init_threads unsigned int SServer_Parameters::init_threads ◆ m_AcceptTimeout ◆ m_Buffer BUF IServer_MessageHandler::m_Buffer private ◆ m_ConnectionPool

Definition at line 200 of file server.hpp.

Referenced by CServer::AddConnectionToPool(), CServer::AddListener(), CServer::CloseConnection(), CServer::CServer(), CServer::DeferConnectionProcessing(), CServer::GetListenerPorts(), CServer::RemoveConnectionFromPool(), CServer::RemoveListener(), CServer::Run(), CServer::SetParameters(), CServer::StartListening(), CServer::WakeUpPollCycle(), CServer::x_DoRun(), and CServer::~CServer().

◆ m_ControlTrigger CTrigger CServer_ConnectionPool::m_ControlTrigger mutableprivate ◆ m_Data TData CServer_ConnectionPool::m_Data private ◆ m_Factory ◆ m_Handler ◆ m_InitThreads unsigned int m_InitThreads protected

Settings for thread pool (which is local to Run):

Number of initial threads

Definition at line 125 of file threaded_server.hpp.

◆ m_ListenerPortsToStop vector<unsigned short> CServer_ConnectionPool::m_ListenerPortsToStop private ◆ m_ListeningStarted bool CServer_ConnectionPool::m_ListeningStarted private ◆ m_Lock ◆ m_LSock ◆ m_MaxConnections unsigned int CServer_ConnectionPool::m_MaxConnections private ◆ m_MaxThreads unsigned int m_MaxThreads protected ◆ m_Mutex CMutex CServer_ConnectionPool::m_Mutex mutableprivate ◆ m_Open bool CServer_Connection::m_Open private ◆ m_Parameters ◆ m_Port [1/2] unsigned short CServer_Listener::m_Port private ◆ m_Port [2/2] ◆ m_QueueSize ◆ m_SeenCR bool IServer_LineMessageHandler::m_SeenCR private ◆ m_Sock ◆ m_Socket CSocket* IServer_ConnectionHandler::m_Socket private ◆ m_SpawnThreshold unsigned int m_SpawnThreshold protected ◆ m_Stream ◆ m_TemporarilyStopListening bool m_TemporarilyStopListening protected ◆ m_ThreadPool ◆ m_ThreadSuffix string CServer::m_ThreadSuffix private ◆ max_connections unsigned int SServer_Parameters::max_connections ◆ max_threads unsigned int SServer_Parameters::max_threads ◆ spawn_threshold unsigned int SServer_Parameters::spawn_threshold

Controls when to spawn more threads.

Definition at line 448 of file server.hpp.

◆ temporarily_stop_listening bool SServer_Parameters::temporarily_stop_listening

Temporarily close listener when queue fills?

Definition at line 438 of file server.hpp.

◆ type ◆ type_lock ◆ CAcceptRequest ◆ CNetCacheServer friend class CNetCacheServer friend

Definition at line 196 of file server.hpp.

◆ CServer_Connection ◆ CServer_ConnectionPool ◆ IServer_MessageHandler

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4