Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cPingCommon Class Reference

#include <cPingCommon.h>

Inheritance diagram for GrayLib::cPingCommon:
GrayLib::cPingClient GrayLib::cPingServer GrayLib::cPingLister

Public Member Functions

 cPingCommon (const IPingProtocol *pForm)
 
virtual ~cPingCommon ()
 
HRESULT OpenPing (const cNetAddress &AddrListen, bool bICMP=false)
 
void ClosePing ()
 
virtual HRESULT onTickPing (OUT BYTE *pPayload, OUT size_t &nPayloadLen, OUT cNetAddress &SockAddr)
 

Public Attributes

cNetSocket m_Socket
 the UDP socket i listen and send on. More...
 
const IPingProtocolm_pForm
 What type of ping protocol are we ? Ping packet formatter. More...
 

Static Public Attributes

static const size_t k_SIZE_MAX = 1400
 max size for UDP PING_QTY type packets. include prefix, header and payload. More...
 

Detailed Description

Base class shared by both cPingClient and cPingServer for UDP pinging

Constructor & Destructor Documentation

◆ cPingCommon()

GrayLib::cPingCommon::cPingCommon ( const IPingProtocol pForm)

◆ ~cPingCommon()

GrayLib::cPingCommon::~cPingCommon ( )
virtual

Member Function Documentation

◆ ClosePing()

void GrayLib::cPingCommon::ClosePing ( )

◆ onTickPing()

HRESULT GrayLib::cPingCommon::onTickPing ( OUT BYTE *  pPayload,
OUT size_t &  nPayloadLen,
OUT cNetAddress SockAddr 
)
virtual

Call this periodically or on event to read incoming data. i am a client or server, check for new requests or getting a response back.

Returns
<0 = ERROR the message type i got. 0 = nothing. IPingProtocol::MSGTYPE_TYPE

Reimplemented in GrayLib::cPingServer.

◆ OpenPing()

HRESULT GrayLib::cPingCommon::OpenPing ( const cNetAddress AddrListen,
bool  bICMP = false 
)

Create a local UDP port for both tx and receive of replies. open some arbitrary UDP port for client to tx/rx on or server to rx/tx on. AddrListen.nFamily = AF_INET AddrListen.wPort= k_NET_PORT_INVALID = arbitrary local port UDP = SOCK_DGRAM, IPPROTO_UDP, m_pForm == cPingGray ICMP = SOCK_RAW, IPPROTO_ICMP, m_pForm == cPingICMP4

Note
the firewall needs to be open for this port to get UDP responses back! use cUPnPNAT ?

Member Data Documentation

◆ k_SIZE_MAX

const size_t GrayLib::cPingCommon::k_SIZE_MAX = 1400
static

max size for UDP PING_QTY type packets. include prefix, header and payload.

◆ m_pForm

const IPingProtocol* GrayLib::cPingCommon::m_pForm

What type of ping protocol are we ? Ping packet formatter.

◆ m_Socket

cNetSocket GrayLib::cPingCommon::m_Socket

the UDP socket i listen and send on.


The documentation for this class was generated from the following files: