C++ common classes
General purpose classes for use across projects (Apache license)
|
Client socket. More...
#include <CClientSocket.h>
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 |
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
Definition at line 33 of file CClientSocket.cpp.
CClientSocket::~CClientSocket | ( | ) | [virtual] |
Definition at line 43 of file CClientSocket.cpp.
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.
int CClientSocket::GetConnectionError | ( | ) | [virtual] |
Last error reported.
Definition at line 368 of file CClientSocket.cpp.
time_t CClientSocket::GetTimeStarted | ( | ) |
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.
BOOL CClientSocket::LastConnectAttemptSuccessful | ( | ) | [protected, virtual] |
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.
BOOL CClientSocket::bConnectAttempt [protected] |
Definition at line 72 of file CClientSocket.h.
BOOL CClientSocket::bDestroying [protected] |
bool CClientSocket::bReuse [protected] |
Definition at line 74 of file CClientSocket.h.
bool CClientSocket::bTcpNoDelay [protected] |
Definition at line 76 of file CClientSocket.h.
CXPlatEvent CClientSocket::cConnectThreadDoneEvent [protected] |
Definition at line 79 of file CClientSocket.h.
CXPlatCriticalSection CClientSocket::cCritSection [protected] |
Definition at line 77 of file CClientSocket.h.
XPLAT_HANDLE CClientSocket::hClientThread [protected] |
Definition at line 71 of file CClientSocket.h.
int CClientSocket::iConnectError [protected] |
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.