//Our listen socket
class CListenSocket : public CUDPSocketAsync
{
public:
//Ctor and Dtor
CListenSocket(CUDPRelay* pFather);
virtual ~CListenSocket();
protected:
//When socket has data in queue
virtual BOOL OnSocketReceive(int iErrorCode);
//No events
NO_OnSocketOOB
NO_OnSocketWrite
NO_OnSocketTimeout
NO_OnSocketConnect
NO_OnSocketClose
NO_OnSocketAccept
private:
//Our father
CUDPRelay* m_pFather;
};
//Our client socket
class CClientSocket : public CUDPSocketAsync
{
public:
//Send data
int SendData(const char* pBuffer,
unsigned long ulBufferSize);
//Ctor and Dtor
CClientSocket(CUDPRelay* pFather,
IP aSourceAddress,
unsigned short usSourcePort);
virtual ~CClientSocket();
protected:
//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_OnSocketOOB
NO_OnSocketWrite
NO_OnSocketConnect
NO_OnSocketClose
NO_OnSocketAccept
private:
//Our father
CUDPRelay* m_pFather;
//Source address
IP m_aSourceAddress;
//Source port
unsigned short m_usSourcePort;
//Our custome source port
unsigned short m_usLocalPort;
};
//Our struct we use to ID an incoming connection
typedef struct _ConnectionData
{
IP aSourceIP;
unsigned short usSourcePort;
//Compare operator
bool operator<(const _ConnectionData& rData)const
{
if (aSourceIP==rData.aSourceIP)
return usSourcePort<rData.usSourcePort;
else
return aSourceIP<rData.aSourceIP;
}
} ConnectionData;
//Our map of connections
typedef std::map<ConnectionData,CClientSocket*> SocketMap;