Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CODEX_Quorum::LocalServer Class Reference

Encapsulation of a local service. More...

#include <LocalServer.h>

Inheritance diagram for CODEX_Quorum::LocalServer:

Inheritance graph
[legend]
Collaboration diagram for CODEX_Quorum::LocalServer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 LocalServer (int port, const SocketBuilder &socketBuilder)
 Constructor.
virtual ~LocalServer ()
 Destructor.
virtual void enable ()
 Create a socket and begin listening.
virtual void disable ()
 Stop listening and destroy the open socket.
int port () const
 The port on which the server is listening.
virtual int set_fd (fd_set *fd_bitmap, SocketBase::StateType s)
 Set the bitmap for this socket.
virtual bool isset_fd (const fd_set *fd_bitmap, SocketBase::StateType s)
 Whether the bitmap is set for this socket.
virtual void processRequest (SocketBase::StateType s)=0
 Process incoming requests.

Protected Member Functions

SocketBasesocket () const
 Returns the socket on which this server is listening.
const SocketBuilderbuilder () const
 Returns the SocketBuilder for this server.
void setSocket (SocketBase *socket)
 Set a SocketBase for this server.

Detailed Description

Encapsulation of a local service.

This is an abstract class for implementing services. Derived classes must implement processRequest(), and probably should reimplement enable() and disable().

A LocalServer is by default not enabled, and the methods enable() and disable() are provided so that a service may be switched on and off during the lifetime of an application, as circumstances dictate. For example, one LocalServer might handle requests that cause other services to be started and stopped, where the requests include key values for a map<> of service/key pairs.

Definition at line 45 of file LocalServer.h.


Constructor & Destructor Documentation

LocalServer::LocalServer int  port,
const SocketBuilder socketBuilder
 

Constructor.

On construction, no socket is created. That is done by enable().

Parameters:
port The port on which this service will listen
socketBuilder The SocketBuilder which will create a new socket, when needed

Definition at line 27 of file LocalServer.cc.

LocalServer::~LocalServer  )  [virtual]
 

Destructor.

The base class destructor cleans up the open socket, if there is one.

Definition at line 34 of file LocalServer.cc.


Member Function Documentation

const SocketBuilder& CODEX_Quorum::LocalServer::builder  )  const [inline, protected]
 

Returns the SocketBuilder for this server.

Definition at line 120 of file LocalServer.h.

Referenced by CODEX_KeyService::ClientServer::processRequest().

void LocalServer::disable  )  [virtual]
 

Stop listening and destroy the open socket.

Derived classes needing to clean up any state on shutdown should reimplement this method. This base-class version should be called explicitly, to ensure the necessary base class cleanup.

Reimplemented in CODEX_Server::InternalVerifier.

Definition at line 53 of file LocalServer.cc.

Referenced by CODEX_Server::InternalVerifier::disable().

void LocalServer::enable  )  [virtual]
 

Create a socket and begin listening.

Derived classes should reimplement this to perform other service initialization tasks needed. This base-class version should be called explicitly, to ensure the necessary base class initialization.

Definition at line 41 of file LocalServer.cc.

References CODEX_Quorum::SocketBase::setup().

bool LocalServer::isset_fd const fd_set *  fd_bitmap,
SocketBase::StateType  s
[virtual]
 

Whether the bitmap is set for this socket.

Some types of sockets may need to know the operation being tested.

Definition at line 76 of file LocalServer.cc.

References CODEX_Quorum::SocketBase::isset_fd().

virtual void CODEX_Quorum::LocalServer::processRequest SocketBase::StateType  s  )  [pure virtual]
 

Process incoming requests.

Derived classes must implement this routine, which is called whenever a connection is made.

Attention:
No further connections may be handled, nor any other actions taken, until this function returns. Consequently, if you do not want your program to block on a request, you must implement some concurrency mechanism, such as an event model or threads. This class makes no assumptions about concurrency.

Implemented in CODEX_Quorum::EchoServer.

int LocalServer::set_fd fd_set *  fd_bitmap,
SocketBase::StateType  s
[virtual]
 

Set the bitmap for this socket.

Some types of sockets may need to know the operation being tested.

Definition at line 69 of file LocalServer.cc.

References CODEX_Quorum::SocketBase::set_fd().

void CODEX_Quorum::LocalServer::setSocket SocketBase socket  )  [inline, protected]
 

Set a SocketBase for this server.

Useful for servers that clone themselves.

Definition at line 126 of file LocalServer.h.

References socket().

Referenced by CODEX_KeyService::ClientActivity::ClientActivity(), and CODEX_Server::InternalVerifier::InternalVerifier().


The documentation for this class was generated from the following files:
Generated on Fri May 6 17:42:28 2005 for COrnell Data EXchange (CODEX) by  doxygen 1.4.1