GClasses
GClasses::GPackageConnection Class Reference

Detailed Description

This is a helper class used by GPackageServer. If you implement a custom connection object for a sub-class of GPackageServer, then it should inherrit from this class.

#include <GSocket.h>

Inheritance diagram for GClasses::GPackageConnection:
GClasses::GTCPConnection

Public Member Functions

 GPackageConnection (SOCKET sock)
 
virtual ~GPackageConnection ()
 
char * next (size_t *pOutSize)
 Returns the next ready package. Returns NULL if no complete package is ready. More...
 
int receive (unsigned int maxBufSize, unsigned int maxPackageSize)
 Receives any available incoming data and adds it to the queue when a complete package is received. Returns 0 if no errors occur (whether or not a full package was received). Returns 1 if the other end disconnected. Returns 2 if the other end tried to send a package that was too big. Returns 3 if the other end breached protocol by sending a bad header. More...
 
- Public Member Functions inherited from GClasses::GTCPConnection
 GTCPConnection (SOCKET sock)
 
virtual ~GTCPConnection ()
 
in_addr ipAddr ()
 Returns the client's IP address for this connection. (You can use inet_ntoa to convert the value this returns to a string.) More...
 
void setSocket (SOCKET sock)
 Sets the socket for this connection. More...
 
SOCKET socket ()
 Returns the socket associated with this connection. More...
 

Public Attributes

unsigned int m_bufSize
 
unsigned int m_header [2]
 
unsigned int m_headerBytes
 
unsigned int m_payloadBytes
 
char * m_pBuf
 
char * m_pCondemned
 
std::queue< GPackageConnectionBufm_q
 

Additional Inherited Members

- Protected Attributes inherited from GClasses::GTCPConnection
SOCKET m_sock
 

Constructor & Destructor Documentation

GClasses::GPackageConnection::GPackageConnection ( SOCKET  sock)
inline
virtual GClasses::GPackageConnection::~GPackageConnection ( )
inlinevirtual

Member Function Documentation

char* GClasses::GPackageConnection::next ( size_t *  pOutSize)

Returns the next ready package. Returns NULL if no complete package is ready.

int GClasses::GPackageConnection::receive ( unsigned int  maxBufSize,
unsigned int  maxPackageSize 
)

Receives any available incoming data and adds it to the queue when a complete package is received. Returns 0 if no errors occur (whether or not a full package was received). Returns 1 if the other end disconnected. Returns 2 if the other end tried to send a package that was too big. Returns 3 if the other end breached protocol by sending a bad header.

Member Data Documentation

unsigned int GClasses::GPackageConnection::m_bufSize
unsigned int GClasses::GPackageConnection::m_header[2]
unsigned int GClasses::GPackageConnection::m_headerBytes
unsigned int GClasses::GPackageConnection::m_payloadBytes
char* GClasses::GPackageConnection::m_pBuf
char* GClasses::GPackageConnection::m_pCondemned
std::queue<GPackageConnectionBuf> GClasses::GPackageConnection::m_q