C++ common classes
General purpose classes for use across projects (Apache license)
CClientSocket Class Reference

Client socket. More...

#include <CClientSocket.h>

Inheritance diagram for CClientSocket:
CConnectionSocket CBaseSocket CHTTPClient

List of all members.

Public Member Functions

 CClientSocket ()
 constructor
virtual ~CClientSocket ()
virtual BOOL ConnectToServer (LPCSTR lpszHostAddress, UINT nHostPort, DWORD dwTimeout=INFINITE)
virtual BOOL ConnectToUnixServer (const char *szUnixSocket, DWORD dwTimeout=INFINITE)
time_t GetTimeStarted ()
virtual int GetConnectionError ()
 Last error reported.
void SetOptions (bool bReuse, int iLinger, bool bTcpNoDelay=false)

Protected Member Functions

virtual BOOL AttemptConnection ()
 Process connections.
virtual BOOL InitiateConnection ()
 Spawn the connection thread.
virtual BOOL LastConnectAttemptSuccessful ()
 Connect attempt successful?
virtual BOOL ConnectDispatcher (DWORD dwTimeout)
 Distribute to either the TCP or UNIX connection code.

Static Protected Member Functions

static unsigned ConnectThread (void *pVoid)
 Client connect thread.

Protected Attributes

BOOL bDestroying
 Actually does the work.
time_t tStarted
XPLAT_HANDLE hClientThread
BOOL bConnectAttempt
int iConnectError
bool bReuse
int iLinger
bool bTcpNoDelay
CXPlatCriticalSection cCritSection
CXPlatEvent cConnectThreadDoneEvent

Detailed Description

Client socket.

Implements a client connection. You should derive a class from this class which implements a ProcessData method for incoming data and also some external method for sending data (internally, you can use the SendDataOut method).

Definition at line 34 of file CClientSocket.h.


Constructor & Destructor Documentation

constructor

Definition at line 33 of file CClientSocket.cpp.

Definition at line 43 of file CClientSocket.cpp.


Member Function Documentation

BOOL CClientSocket::AttemptConnection ( ) [protected, virtual]

Process connections.

Definition at line 333 of file CClientSocket.cpp.

BOOL CClientSocket::ConnectDispatcher ( DWORD  dwTimeout) [protected, virtual]

Distribute to either the TCP or UNIX connection code.

Definition at line 77 of file CClientSocket.cpp.

unsigned CClientSocket::ConnectThread ( void pVoid) [static, protected]

Client connect thread.

Definition at line 316 of file CClientSocket.cpp.

BOOL CClientSocket::ConnectToServer ( LPCSTR  lpszHostAddress,
UINT  nHostPort,
DWORD  dwTimeout = INFINITE 
) [virtual]

Connect to a server WARNING - if you are going to reuse this object for multiple connections, then you MUST call TerminateConnection after each connection transaction is complete to clean up resources.

Definition at line 197 of file CClientSocket.cpp.

BOOL CClientSocket::ConnectToUnixServer ( const char *  szUnixSocket,
DWORD  dwTimeout = INFINITE 
) [virtual]

Definition at line 159 of file CClientSocket.cpp.

Last error reported.

Definition at line 368 of file CClientSocket.cpp.

Definition at line 266 of file CClientSocket.cpp.

BOOL CClientSocket::InitiateConnection ( ) [protected, virtual]

Spawn the connection thread.

Definition at line 274 of file CClientSocket.cpp.

Connect attempt successful?

Definition at line 360 of file CClientSocket.cpp.

void CClientSocket::SetOptions ( bool  bReuse,
int  iLinger,
bool  bTcpNoDelay = false 
)

Set socket options - must be called BEFORE ConnectToServer Normally, the defaults are fine unless you are going to create and tear down lots of connections

Definition at line 66 of file CClientSocket.cpp.


Member Data Documentation

Definition at line 72 of file CClientSocket.h.

Actually does the work.

data member

Definition at line 69 of file CClientSocket.h.

bool CClientSocket::bReuse [protected]

Definition at line 74 of file CClientSocket.h.

bool CClientSocket::bTcpNoDelay [protected]

Definition at line 76 of file CClientSocket.h.

Definition at line 79 of file CClientSocket.h.

Definition at line 77 of file CClientSocket.h.

Definition at line 71 of file CClientSocket.h.

Definition at line 73 of file CClientSocket.h.

int CClientSocket::iLinger [protected]

Definition at line 75 of file CClientSocket.h.

time_t CClientSocket::tStarted [protected]

Definition at line 70 of file CClientSocket.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines