Class CTCPRelay Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: Custom Code in Header Public SectionNext page: Custom Code in Source After Includes    Show member index
Custom Code in Header Private Section Declared in:
TCPRelay.h

'Custom Code' icon -- Shortcut to top of page. Custom Code

//Our accept socket
class CAcceptSocket : public CTCPSocketAsync
{
public:
    //Ctor and Dtor
    CAcceptSocket(CTCPRelay* pFather);
    virtual ~CAcceptSocket();
protected:
    //When a socket can accept an incoming connection
    virtual BOOL OnSocketAccept(int iErrorCode);

    //No events
    NO_OnSocketOOB
    NO_OnSocketWrite
    NO_OnSocketTimeout
    NO_OnSocketConnect
    NO_OnSocketClose
    NO_OnSocketReceive
private:
    //Our father
    CTCPRelay* m_pFather;
};
//Our client socket
class CClientSocket : public CTCPSocketAsync
{
public:
    //Send data over the sockets
    virtual int Send(const char* pBuffer,
                     unsigned long ulBufferLength);

    //Stop the sockets
    void Stop();

    //Set the connection ID
    void SetConnectionID(ConnectionID aConnectionID);

    //Try to connect
    void Connect();

    //Set the other side
    void SetSocket(CClientSocket* pSocket);

    //Ctor and Dtor
    CClientSocket(CTCPRelay* pFather,
                  CClientSocket* pSocket);
    virtual ~CClientSocket();
protected:
    //When a socket got a connect event (after calling connect)
    virtual BOOL OnSocketConnect(int iErrorCode);

    //When a socket was closed
    virtual BOOL OnSocketClose(int iErrorCode);

    //When socket has data in queue
    virtual BOOL OnSocketReceive(int iErrorCode);

    //When a timeout occured (implemented at library level)
    //User should return 0, if proccessed the message
    virtual BOOL OnSocketTimeout();

    //No events
    NO_OnSocketAccept
    NO_OnSocketOOB
    NO_OnSocketWrite
private:
    //Our father
    CTCPRelay* m_pFather;

    //Our other side
    CClientSocket* m_pSocket;

    //Our connection ID
    ConnectionID m_aConnectionID;

    //Are we the incoming
    BOOL m_bIncoming;

    //Our CS
    CGenericCriticalSection* m_pCSection;

    //Do we have an event
    BOOL m_bEvent;
};
//Our struct of two sockets
typedef struct _SocketData
{
    CClientSocket*  pIncomingConnection;
    CClientSocket*  pOutgoingConnection;
} SocketData;

//Our map of sockets (according to connection IDs)
typedef std::map<ConnectionID,SocketData> ClientMap;

'See Also' icon -- Shortcut to top of page. See Also

Class Overview Class Overview  |  Public base class CRelay  |  Hierarchy Chart Hierarchy Chart


Get Surveyor!This web site was generated using Surveyor V4.50.811.1.  Click here for more information. Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003.