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

CTCPConnectionLost Class Reference

#include <CTCPConnectionLost.h>

List of all members.

Public Member Functions

 CTCPConnectionLost (CSocket *pSocket, const char *pDoing)
 CTCPConnectionLost (const CTCPConnectionLost &rhs)
virtual ~CTCPConnectionLost ()
CTCPConnectionLostoperator= (const CTCPConnectionLost &rhs)
int operator== (const CTCPConnectionLost &rhs)
 STD (string) getHost() const
 STD (string) getPort() const
virtual const char * ReasonText () const

Protected Member Functions

void setHost (const STD(string)&rHost)
void setPort (const STD(string)&rPort)
void Host (CSocket *pSocket)
void Port (CSocket *pSocket)

Private Member Functions

 STD (string) m_Host
 STD (string) m_Port
 STD (string) m_ReasonText


Detailed Description

Encapsulate the connection lost exception. This exception is thrown when a read is attempted on a busted socket.

Definition at line 308 of file CTCPConnectionLost.h.


Constructor & Destructor Documentation

CTCPConnectionLost::CTCPConnectionLost CSocket pSocket,
const char *  pDoing
 

'Normal constructor' This is called prior to throwing a connection lost exception. The host and port information are gotten from the socket. The reason the connection was lost is currently in errno.

Parameters:
pSocket - the socket which just lost connection.
pDoing -Describes what the socket was doing when the exceptional condition occured.

Definition at line 314 of file CTCPConnectionLost.cpp.

References Host(), and Port().

CTCPConnectionLost::CTCPConnectionLost const CTCPConnectionLost rhs  ) 
 

Copy constructor.. used by the compiler to generate termporary variables and of course, by throw to create a scope-safe copy of the exception being thrown.

Parameters:
rhs - the reference object being copied.

Definition at line 325 of file CTCPConnectionLost.cpp.

virtual CTCPConnectionLost::~CTCPConnectionLost  )  [inline, virtual]
 

Definition at line 322 of file CTCPConnectionLost.h.


Member Function Documentation

void CTCPConnectionLost::Host CSocket pSocket  )  [protected]
 

Extract the peer's hostname from the socket. This is done as follows:

  • The fd of the socket is gotten.
  • getpeername(2) is called to get the peer address.
  • gethostbyaddr(3) is called to translate this (if possible) to a hostname.
  • If gethostbyaddr(3) failed to return a useful hostname, inet_addr(3) is used to translate the peer address into a dotted ip string.

Parameters:
pSocket - Pointer to the socket for which this information is to be retrieved.
NOTE: We assume gethostbyaddr(3) and inet_addr(3) are not thread-safe.

Definition at line 403 of file CTCPConnectionLost.cpp.

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

Referenced by CTCPConnectionLost().

CTCPConnectionLost & CTCPConnectionLost::operator= const CTCPConnectionLost rhs  ) 
 

Assignment operator. Only slightly different than copy construction:

  • Protect against self assign.
  • Return *this.
  • this is already fully constructed.

Parameters:
rhs - Reference to rhs of assignment operation.

Definition at line 340 of file CTCPConnectionLost.cpp.

int CTCPConnectionLost::operator== const CTCPConnectionLost rhs  ) 
 

Equality comparison.

Parameters:
rhs The right hand side of the ==.

Definition at line 355 of file CTCPConnectionLost.cpp.

void CTCPConnectionLost::Port CSocket pSocket  )  [protected]
 

For a given CSocket* fills in m_Port. This is done by:

  • Retreiving the socket fd.
  • Asking getpeername(2) who is attached to the socket.
  • Asking getservbyport(3) to return the service name from the port.
  • If getservbyport(3) failed, the numeric service name is encoded.
  • If getpeername(2) failed, the port -unavailable- is returned.

Parameters:
pSocket - Pointer to the soket about which we're asking.
NOTE: We assume that getservbyport(3) is not thread safe.

Definition at line 443 of file CTCPConnectionLost.cpp.

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

Referenced by CTCPConnectionLost().

const char * CTCPConnectionLost::ReasonText  )  const [virtual]
 

Return the reason for the exception as a textual string of the form:

Connection with host m_Host at m_Port was lost: CErrnoException::ReasonText()

Definition at line 373 of file CTCPConnectionLost.cpp.

void CTCPConnectionLost::setHost const STD(string)&  rHost  )  [inline, protected]
 

Definition at line 339 of file CTCPConnectionLost.h.

void CTCPConnectionLost::setPort const STD(string)&  rPort  )  [inline, protected]
 

Definition at line 342 of file CTCPConnectionLost.h.

CTCPConnectionLost::STD string   )  const [inline]
 

Definition at line 333 of file CTCPConnectionLost.h.

CTCPConnectionLost::STD string   )  const [inline]
 

Definition at line 331 of file CTCPConnectionLost.h.

CTCPConnectionLost::STD string   )  [mutable, private]
 

CTCPConnectionLost::STD string   )  [private]
 

CTCPConnectionLost::STD string   )  [private]
 


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