00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #if !defined(AFX_PINGSOCKET_H__469EE2E5_24E2_4DAA_A2BD_4A7DE284F4D4__INCLUDED_)
00037 #define AFX_PINGSOCKET_H__469EE2E5_24E2_4DAA_A2BD_4A7DE284F4D4__INCLUDED_
00038
00039 #if _MSC_VER > 1000
00040 #pragma once
00041 #endif // _MSC_VER > 1000
00042
00043 #include "ICMPSocketAsync.h"
00044
00045 KOMODIA_NAMESPACE_START
00046
00047 class CPingSocket : public CICMPSocketAsync
00048 {
00049 public:
00050
00051 void SetID(unsigned short usID);
00052
00053
00054 void SetSequence(unsigned short usSequence);
00055
00056
00057 void SetUseSameID(BOOL bSameID);
00058
00059
00060 int GetDataSize()const;
00061
00062
00063 unsigned char GetTTL()const;
00064
00065
00066 DWORD GetTimeElapsed()const;
00067
00068
00069 BOOL IsTimeout()const;
00070
00071
00072 IP GetReplyingAddress()const;
00073
00074
00075 virtual BOOL Ping(const std::string& rDestinationAddress,
00076 DWORD dwTimeout=3000);
00077
00078 virtual BOOL Ping(IP aDestinationAddress,
00079 DWORD dwTimeout=3000);
00080
00081
00082 BOOL IsPingDone()const;
00083
00084
00085 CPingSocket();
00086 virtual ~CPingSocket();
00087 protected:
00088
00089 NO_OnSocketAccept
00090 NO_OnSocketConnect
00091 NO_OnSocketClose
00092 NO_OnSocketOOB
00093 NO_OnSocketWrite
00094
00095 virtual BOOL OnSocketTimeout();
00096 virtual BOOL OnSocketReceive(int iErrorCode);
00097
00098
00099
00100
00101 virtual void PingDone(BOOL bTimeout);
00102
00103
00104
00105
00106
00107
00108
00109
00110 virtual void PingDoneData(IP aReplyingAddress,
00111 unsigned char ucTTL,
00112 DWORD dwTimeElapsed,
00113 int iDataSize,
00114 unsigned short usID,
00115 BOOL bTTLExpired);
00116
00117
00118 virtual BOOL IsIDOK(unsigned short usID,
00119 unsigned short usSequence)const;
00120 private:
00121
00122 DWORD m_dwLastTick;
00123
00124
00125 BOOL m_bPingDone;
00126
00127
00128 unsigned short m_usLastPingID;
00129
00130
00131 unsigned short m_usLastPingSequence;
00132
00133
00134 IP m_aReplyingAddress;
00135
00136
00137 DWORD m_dwTimeElapsed;
00138
00139
00140 unsigned char m_ucTTL;
00141
00142
00143 BOOL m_bTimeout;
00144
00145
00146 int m_iDataSize;
00147
00148
00149 BOOL m_bSameID;
00150
00151
00152 DWORD m_dwTimeout;
00153 };
00154
00155 KOMODIA_NAMESPACE_END
00156
00157 #endif // !defined(AFX_PINGSOCKET_H__469EE2E5_24E2_4DAA_A2BD_4A7DE284F4D4__INCLUDED_)