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

CServerConnectionEvent Class Reference

#include <CServerConnectionEvent.h>

Inheritance diagram for CServerConnectionEvent:

CFileEvent CEvent CRegisteredObject CNamedObject List of all members.

Public Member Functions

 CServerConnectionEvent (CSocket &sock)
 CServerConnectionEvent (const char *pName, CSocket &sock)
 CServerConnectionEvent (const STD(string)&rName, CSocket &sock)
 CServerConnectionEvent (const STD(string)&rServiceName)
 CServerConnectionEvent (const char *pName, const STD(string)&rServiceName)
 CServerConnectionEvent (const STD(string)&rName, const STD(string)&rServiceName)
 CServerConnectionEvent (int nFd)
 CServerConnectionEvent (const char *pName, int nFd)
 CServerConnectionEvent (const STD(string)&rName, int nFd)
 ~CServerConnectionEvent ()
CSocketgetSocket ()
bool isDynamicSocket () const
virtual void OnConnection (CSocket *pPeer)
virtual void OnReadable (STD(istream)&rStream)
virtual STD (string) DescribeSelf()

Protected Member Functions

void setSocket (CSocket *pSocket)
void setDynamic (bool fDyn)
void ConfigureSocket (const STD(string)&rSvcName)
void ConfigureSocket (int nPort)
int Protocol ()

Private Member Functions

 CServerConnectionEvent (const CServerConnectionEvent &rhs)
CServerConnectionEventoperator= (const CServerConnectionEvent &rhs)
int operator== (const CServerConnectionEvent &rhs)

Private Attributes

CSocketm_pService
 Server listener socket.
bool m_fDeleteSocket
 true if destructor delete socket.

Constructor & Destructor Documentation

CServerConnectionEvent::CServerConnectionEvent CSocket rSocket  ) 
 

Construct an anonymous connection listener from an existing socket object. In this case, it will not be necessary for the destructor to eliminate the socket.

Parameters:
rSocket - An existing socket, bound, listening and ready to accept when the fd becomes readable.

Definition at line 312 of file CServerConnectionEvent.cpp.

CServerConnectionEvent::CServerConnectionEvent const char *  pname,
CSocket rSocket
 

Construct a named connection listener from and existing socket object.

Parameters:
pname - char* pointer to the name of the event.
rSocket - Reference to existing socket.

Definition at line 324 of file CServerConnectionEvent.cpp.

CServerConnectionEvent::CServerConnectionEvent const STD(string)&  rName,
CSocket sock
 

CServerConnectionEvent::CServerConnectionEvent const STD(string)&  rServiceName  ) 
 

CServerConnectionEvent::CServerConnectionEvent const char *  pName,
const STD(string)&  rServiceName
 

CServerConnectionEvent::CServerConnectionEvent const STD(string)&  rName,
const STD(string)&  rServiceName
 

CServerConnectionEvent::CServerConnectionEvent int  nFd  ) 
 

Construct an anonymous Connection listener given a file id which represents a bound and listening socket.

Parameters:
nFd - A file descriptor which is a bound and listening socket.

Definition at line 395 of file CServerConnectionEvent.cpp.

CServerConnectionEvent::CServerConnectionEvent const char *  pName,
int  nFd
 

Construct a named connection listener given a file id which represents a bound and listening socket.

Parameters:
pName - char* name to be given to the socket.
nFd - File descriptor representing a bound and listening sock.

Definition at line 408 of file CServerConnectionEvent.cpp.

CServerConnectionEvent::CServerConnectionEvent const STD(string)&  rName,
int  nFd
 

CServerConnectionEvent::~CServerConnectionEvent  ) 
 

Destructor... if m_fDelete socket is true, then the socket is deleted. otherwise just closed.

Definition at line 432 of file CServerConnectionEvent.cpp.

References m_pService, and CSocket::Shutdown().

CServerConnectionEvent::CServerConnectionEvent const CServerConnectionEvent rhs  )  [private]
 


Member Function Documentation

void CServerConnectionEvent::ConfigureSocket int  nPort  )  [protected]
 

Utility function to configure a socket. The port id is used to bind the socket and set it into listen mode.

Note:
It's possible that a socket can come into this function in the wrong mode if there are program errors. In that case, the CSocket calls made may throw an exception. We catch all exceptions, if necessary delete the socket object and rethrow to the caller.
Parameters:
nPort - The number of the port to bind the socket to.
Note:
On non exceptional exit from this function, m_pService is bound to the selected service and the socket is in the listen state.

Definition at line 520 of file CServerConnectionEvent.cpp.

References ConfigureSocket().

void CServerConnectionEvent::ConfigureSocket const STD(string)&  rSvcName  )  [protected]
 

Referenced by ConfigureSocket().

CSocket* CServerConnectionEvent::getSocket  )  [inline]
 

Definition at line 369 of file CServerConnectionEvent.h.

bool CServerConnectionEvent::isDynamicSocket  )  const [inline]
 

Definition at line 373 of file CServerConnectionEvent.h.

void CServerConnectionEvent::OnConnection CSocket pPeer  )  [virtual]
 

This member function is called whenever a connection is available. The default implementation rejects the connection and destroys the connection object. It's assumed that the user of this class will subclass it and override this member with code to generate an object to manage the connection. How this is done depends on the needs of the application. One typical way to do this would be to create a CServerInstance derived object and enable it. This would start up a server instance in a separate thread, to handle requests in a application synchronized manner.

Parameters:
pPeer - pointer to dynamically created socket representing the connection peer.

Definition at line 452 of file CServerConnectionEvent.cpp.

References CSocket::Shutdown().

virtual void CServerConnectionEvent::OnReadable STD(istream)&  rStream  )  [virtual]
 

CServerConnectionEvent& CServerConnectionEvent::operator= const CServerConnectionEvent rhs  )  [private]
 

int CServerConnectionEvent::operator== const CServerConnectionEvent rhs  )  [private]
 

int CServerConnectionEvent::Protocol  )  [protected]
 

Determine the correct protocol id for a socket(2) call. We only support tcp as the protocol. This function encapsulates the call to getprotobyname(3), and the decode of the arguments. getprotobyname(3) is assumed to be non-reentrant/non-recursive and therefore the call to it is serialized to the application.

Failures are not considered possible, so are asserted against, since the only acceptable protocol is "TCP".

Return values:
int - a protocol id suitable for the last parameter of the socket(2) call.

Definition at line 542 of file CServerConnectionEvent.cpp.

References CApplicationSerializer::getInstance(), CThreadRecursiveMutex::Lock(), and CThreadRecursiveMutex::UnLock().

void CServerConnectionEvent::setDynamic bool  fDyn  )  [inline, protected]
 

Definition at line 382 of file CServerConnectionEvent.h.

References m_fDeleteSocket.

void CServerConnectionEvent::setSocket CSocket pSocket  )  [inline, protected]
 

Definition at line 379 of file CServerConnectionEvent.h.

References m_pService.

virtual CServerConnectionEvent::STD string   )  [virtual]
 

The name of the object

Reimplemented from CFileEvent.


Member Data Documentation

bool CServerConnectionEvent::m_fDeleteSocket [private]
 

true if destructor delete socket.

Definition at line 333 of file CServerConnectionEvent.h.

Referenced by setDynamic().

CSocket* CServerConnectionEvent::m_pService [private]
 

Server listener socket.

Definition at line 332 of file CServerConnectionEvent.h.

Referenced by setSocket(), and ~CServerConnectionEvent().


The documentation for this class was generated from the following files:
Generated on Thu Jan 6 16:58:44 2005 for Spectrodaq External Event Framework by  doxygen 1.3.9.1