C++ common classes
General purpose classes for use across projects (Apache license)
|
CConnectionSocket - Establish a connection with the caller. More...
#include <CConnectionSocket.h>
Public Types | |
enum | { CS_BUFFER_SIZE = 0x2000 } |
enum | ECLOSE_TYPE { CLOSE_ACTIVE = 0, CLOSE_WAIT = 1, CLOSE_IMMEDIATE = 2 } |
Public Member Functions | |
CConnectionSocket (CBaseSocket *pOwner, struct sockaddr *pAddr=NULL) | |
Operations. | |
virtual | ~CConnectionSocket () |
virtual XPLAT_HANDLE | ServiceConnection (SOCKET sNewSocket) |
Methods. | |
virtual void | TerminateConnection (ECLOSE_TYPE eRequest=CLOSE_WAIT) |
Closes service thread by closing socket. | |
virtual time_t | GetTimeConnected () |
Return the time the connection was initiated. | |
virtual BOOL | IsConnected () |
Connected? | |
virtual struct sockaddr_in | GetSocketAddress () |
Get socket address. | |
Public Attributes | |
XPLAT_HANDLE | hThread |
Protected Member Functions | |
virtual int | ReceiveData (void *lpBuf, int nBufLen) |
Receive the data from socket, external buffer. | |
virtual int | ReceiveData () |
Receive the data from socket, internal buffer. | |
virtual BOOL | SendDataOut (LPSTR lpData, int nPacketSize, int nTotalLength) |
Send data. | |
virtual BOOL | ProcessData (unsigned char *lpData, int iLen)=0 |
Pure virtual function to process data. | |
virtual BOOL | GetHandshake (unsigned char **ucHS, int &iLen) |
virtual void | Disconnected () |
When the ServiceConnectionThread stops, this gets called. | |
virtual int | HandleConnection () |
Called by ServiceConnectionThread to actually do the work. | |
Static Protected Member Functions | |
static unsigned | ServiceConnectionThread (void *pVoid) |
Thread function to listen to data, etc. | |
Protected Attributes | |
unsigned char | ucBuffer [CS_BUFFER_SIZE] |
CBaseSocket * | cOwner |
time_t | tConnected |
struct sockaddr_in | sAddr |
struct sockaddr_un | sUAddr |
ECLOSE_TYPE | eRequestClose |
CConnectionSocket - Establish a connection with the caller.
Definition at line 31 of file CConnectionSocket.h.
anonymous enum |
Definition at line 38 of file CConnectionSocket.h.
Definition at line 42 of file CConnectionSocket.h.
CConnectionSocket::CConnectionSocket | ( | CBaseSocket * | pOwner, |
struct sockaddr * | pAddr = NULL |
||
) |
Operations.
Definition at line 32 of file CConnectionSocket.cpp.
CConnectionSocket::~CConnectionSocket | ( | ) | [virtual] |
Definition at line 45 of file CConnectionSocket.cpp.
virtual void CConnectionSocket::Disconnected | ( | ) | [inline, protected, virtual] |
When the ServiceConnectionThread stops, this gets called.
Called when the socket is disconnecting WARNING: this may occasionally get called more than once - code appropriately
Reimplemented in CHTTPClient.
Definition at line 83 of file CConnectionSocket.h.
virtual BOOL CConnectionSocket::GetHandshake | ( | unsigned char ** | ucHS, |
int & | iLen | ||
) | [inline, protected, virtual] |
Get handshake. Return TRUE if ptr and int filled This is sent when a connection is established. Redefine to have server send a connection message.
Definition at line 78 of file CConnectionSocket.h.
struct sockaddr_in CConnectionSocket::GetSocketAddress | ( | ) | [read, virtual] |
Get socket address.
Definition at line 527 of file CConnectionSocket.cpp.
time_t CConnectionSocket::GetTimeConnected | ( | ) | [virtual] |
Return the time the connection was initiated.
Definition at line 506 of file CConnectionSocket.cpp.
int CConnectionSocket::HandleConnection | ( | ) | [protected, virtual] |
Called by ServiceConnectionThread to actually do the work.
Definition at line 339 of file CConnectionSocket.cpp.
BOOL CConnectionSocket::IsConnected | ( | ) | [virtual] |
Connected?
Definition at line 516 of file CConnectionSocket.cpp.
virtual BOOL CConnectionSocket::ProcessData | ( | unsigned char * | lpData, |
int | iLen | ||
) | [protected, pure virtual] |
Pure virtual function to process data.
Implemented in CHTTPClient.
int CConnectionSocket::ReceiveData | ( | void * | lpBuf, |
int | nBufLen | ||
) | [protected, virtual] |
Receive the data from socket, external buffer.
Definition at line 305 of file CConnectionSocket.cpp.
int CConnectionSocket::ReceiveData | ( | ) | [protected, virtual] |
Receive the data from socket, internal buffer.
Definition at line 331 of file CConnectionSocket.cpp.
BOOL CConnectionSocket::SendDataOut | ( | LPSTR | lpData, |
int | nPacketSize, | ||
int | nTotalLength | ||
) | [protected, virtual] |
Send data.
Definition at line 139 of file CConnectionSocket.cpp.
XPLAT_HANDLE CConnectionSocket::ServiceConnection | ( | SOCKET | sNewSocket | ) | [virtual] |
Methods.
Starts thread to service client. Returns thread handle.
Definition at line 94 of file CConnectionSocket.cpp.
unsigned CConnectionSocket::ServiceConnectionThread | ( | void * | pVoid | ) | [static, protected] |
Thread function to listen to data, etc.
Definition at line 488 of file CConnectionSocket.cpp.
void CConnectionSocket::TerminateConnection | ( | ECLOSE_TYPE | eRequest = CLOSE_WAIT | ) | [virtual] |
Closes service thread by closing socket.
Definition at line 59 of file CConnectionSocket.cpp.
CBaseSocket* CConnectionSocket::cOwner [protected] |
Definition at line 95 of file CConnectionSocket.h.
ECLOSE_TYPE CConnectionSocket::eRequestClose [protected] |
Definition at line 99 of file CConnectionSocket.h.
Definition at line 63 of file CConnectionSocket.h.
struct sockaddr_in CConnectionSocket::sAddr [protected] |
Definition at line 97 of file CConnectionSocket.h.
struct sockaddr_un CConnectionSocket::sUAddr [protected] |
Definition at line 98 of file CConnectionSocket.h.
time_t CConnectionSocket::tConnected [protected] |
Definition at line 96 of file CConnectionSocket.h.
unsigned char CConnectionSocket::ucBuffer[CS_BUFFER_SIZE] [protected] |
Definition at line 94 of file CConnectionSocket.h.