?? cping.htm
字號:
<html>
<head>
<title>CPing v1.21</title>
</head>
<body bgcolor="#FFFFFF">
<p align="left"><img src="cping.gif" alt="smtp.gif (295 bytes)" width="39" height="37"><font
face="Arial"><big><big><big><big><strong>CPing v1.21</strong></big></big></big></big></font></p>
<p><font face="Arial">Welcome to <strong>CPing</strong>, a freeware MFC class to
encapsulate the PING protocol. </font></p>
<p> </p>
<p> </p>
<p> </p>
<table>
<tr>
<td><font face="Arial"><a href="#Features">Features</a></font></td>
</tr>
<tr>
<td><font face="Arial"><a href="#Usage">Usage</a></font></td>
</tr>
<tr>
<td><font face="Arial"><a href="#History">History</a></font></td>
</tr>
<tr>
<td><font face="Arial"><a href="#APIReference">API Reference</a></font></td>
</tr>
<tr>
<td><font face="Arial"><a href="#Enhancements">Planned Enhancements</a></font></td>
</tr>
<tr>
<td><font face="Arial"><a href="#Contact">Contacting the Author</a></font></td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p><font face="Arial"><a name="Features"></a><big><strong><big>Features</big></strong></big>
</font>
<ul>
<li><font color="#000000" size="3" face="Arial">Simple and clean C++ interface.</font></li>
<li><font color="#000000" size="3" face="Arial">The interface provided is synchronous which
provides an easier programming model than using asynchronous sockets.</font></li>
<li><font color="#000000" size="3" face="Arial">A configurable timeout for the connection
can be set through the class API.</font></li>
<li><font color="#000000" size="3" face="Arial">The classes are fully Unicode compliant and
include Unicode built options in the workspace file.</font></li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<p><a name="Usage"></a><font face="Arial"><big><big><strong>Usage</strong></big></big></font>
<ul>
<li><font color="#000000" size="3" face="Arial">To use the class in your code simply include
ping.cpp in your project and #include ping.h in which ever of your modules needs to make
calls to the class. </font></li>
<li><font face="Arial">Your code will need to include MFC either statically or dynamically.</font></li>
<li><font face="Arial">You will need to have a functioning winsock stack installed as the
code links to winsock.dll.</font></li>
<li><font face="Arial">You will also need to have winsock.h or afxsock.h and afxpriv.h in
your precompiled header. The code will work just aswell in a GUI or console app. The code
should also work in a multithreaded application, although it has not be explicitly tested
in this scenario.</font></li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<p><font face="Arial"><big><a name="History"></a></big><font color="#000000" size="5"><strong>History</strong></font></font></p>
<p><font color="#000000" size="3" face="Arial"><strong>V1.0 (11th June 1998)</strong></font>
<ul>
<li><font face="Arial"><font size="3"><font color="#000000">Initial public release.</font></font><big>
</big></font></li>
</ul>
<p><font color="#000000" size="3" face="Arial"><strong>V1.1 (23rd June 1998)</strong></font>
<ul>
<li><font face="Arial">The class now supports using Winsock 2 calls instead of using the
ICMP dll. To use Winsock 2 calls in CPing instead of the ICMP dll, just define the
preprocessor constant "CPING_USE_WINSOCK2" and don't forget to link to
"ws2_32.lib".</font></li>
</ul>
<p><font color="#000000" size="3" face="Arial"><strong>V1.2 (30th July 1998)</strong></font>
<ul>
<li><font face="Arial">Can now use both Winsock 2 calls and ICMP style calls at the same
time with the use of 2 preprocessor directives.</font></li>
<li><font face="Arial">sample program now use generic entry point _tmain.</font></li>
<li><font face="Arial">Got rid of a 2 level 4 compiler warnings.</font></li>
<li><font face="Arial">Fixed a problem with the cleanup of ICMP dll usage.</font></li>
<li><font face="Arial">Tidied up and optimized the usage of static variables.</font></li>
</ul>
<p><font color="#000000" size="3" face="Arial"><strong>V1.21 (9th November 1998)</strong></font>
<ul>
<li><font face="Arial">Now ships with a VC 5 workspace file instead of VC 6. This is mainly
because VC 6 is still not as stable as VC 5 plus a lot of people have not migrated to it
yet.</font></li>
<li><font face="Arial">Workspace file now includes configurations to allow both the Winsock
2 and ICMP based code to be exercised.</font></li>
<li><font face="Arial">Fixed a level 4 warning which was occuring.</font></li>
<li><font face="Arial">Removed a number of compiler errors which was occuring when code was
compiled to use the ICMP or Winsock 2.</font></li>
<li><font face="Arial">Fixed a bug whereby a ping to a non-existant host using the Winsock 2
method blocked indefinitely.</font></li>
<li><font face="Arial">Fixed a socket handle leak which was occuring if the Winsock 2 method
of pinging was used.</font></li>
<li><font face="Arial">Fixed erorr in API documentation when compared with the actual header
file.</font></li>
<li><font face="Arial">Fixed error in API documentation regarding default timeouts value.</font></li>
</ul>
<p> </p>
<p class="crt"><font face="Arial"><a name="APIReference"></a><big><big><strong>API
Reference</strong></big></big></font></p>
<p><font face="Arial">The API consists of the the single public member "Ping" of
the class CPing</font></p>
<p> </p>
<p> </p>
<p><big><strong><font face="Arial">CPing::Ping1</font></strong></big></p>
<p><font face="Arial"><strong>BOOL CPing::Ping1(LPCTSTR </strong><em>pszHostName</em><strong>,
CPingReply</strong>& pr, <strong>UCHAR</strong> nTTL = <strong>10, DWORD </strong><em>dwTimeout</em><strong>
= 5000, UCHAR</strong> nPacketSize = <strong>32</strong>) const</font></p>
<p class="rl"><font face="Arial"><strong>Return Value</strong></font></p>
<p class="t"><font face="Arial">If the function succeeds, the return value is TRUE. If the
function fails, the return value is FALSE. To get extended error information, call
::GetLastError.</font></p>
<p><font face="Arial"><strong>Parameters</strong></font></p>
<p><font face="Arial"><em>pszHostName</em> The network address of the socket to connect
to: a machine name such as “ftp.yourisp.com”, or a dotted number such as
“128.56.22.8” will both work.</font></p>
<p><font face="Arial"><em>pr</em> This is a reference to a structure which will be filled
in upon successful return of this function. Currently it contains just two members,
namely:</font></p>
<p><font face="Arial"> <em>Address</em> This is
th IP address of the replier</font></p>
<p><font face="Arial"> <em>RTT</em> This is the round
trip time in Milliseconds</font></p>
<p><font face="Arial"><em>dwTimeout</em> This is the timeout to use for connections in
milliseconds.</font></p>
<p><font face="Arial"><em>nTTL</em> This is the time to live of the ICMP packet to be
sent. For those unfamilar with the low level details of IP, this is the maximum number of
routers through which this packet should travel. Each time an IP packet goes through a
router, its TTL value is decremented by 1. Eventually when a packet is received with a TTL
of 1, it is not forwarded and instead an ICMP reply is generated. This prevents the
network from becoming flooded with old IP packets. As an aside this is the basis of how
traceroute is implemented.</font></p>
<p><font face="Arial"><em>nPacketSize</em> This is the size of the ICMP packet to send.</font></p>
<p><font face="Arial"><strong>Remarks</strong></font></p>
<p><font face="Arial">Internally this function will use the ICMP dll to do a ping. To make
this function available you will need to define the CPING_USE_ICMP preprocessor macro and
link to the winsock v1.1dll namely "wsock32.dll".</font></p>
<p> </p>
<p> </p>
<p><big><strong><font face="Arial">CPing::Ping2</font></strong></big></p>
<p><font face="Arial"><strong>BOOL CPing::Ping2(LPCTSTR </strong><em>pszHostName</em><strong>,
CPingReply</strong>& pr, <strong>DWORD </strong><em>dwTimeout</em><strong> = 5000,
UCHAR</strong> nTTL = <strong>10</strong>, <strong>UCHAR</strong> nPacketSize = <strong>32</strong>)
const</font></p>
<p class="rl"><font face="Arial"><strong>Return Value</strong></font></p>
<p class="t"><font face="Arial">If the function succeeds, the return value is TRUE. If the
function fails, the return value is FALSE. To get extended error information, call
::GetLastError.</font></p>
<p><font face="Arial"><strong>Parameters</strong></font></p>
<p><font face="Arial"><em>pszHostName</em> The network address of the socket to connect
to: a machine name such as “ftp.yourisp.com”, or a dotted number such as
“128.56.22.8” will both work.</font></p>
<p><font face="Arial"><em>pr</em> This is a reference to a structure which will be filled
in upon successful return of this function. Currently it contains just two members,
namely:</font></p>
<p><font face="Arial"> <em>Address</em> This is
th IP address of the replier</font></p>
<p><font face="Arial"> <em>RTT</em> This is the round
trip time in Milliseconds</font></p>
<p><font face="Arial"><em>dwTimeout</em> This is the timeout to use for connections in
milliseconds.</font></p>
<p><font face="Arial"><em>nTTL</em> This is the time to live of the ICMP packet to be
sent. For those unfamilar with the low level details of IP, this is the maximum number of
routers through which this packet should travel. Each time an IP packet goes through a
router, its TTL value is decremented by 1. Eventually when a packet is received with a TTL
of 1, it is not forwarded and instead an ICMP reply is generated. This prevents the
network from becoming flooded with old IP packets. As an aside this is the basis of how
traceroute is implemented.</font></p>
<p><font face="Arial"><em>nPacketSize</em> This is the size of the ICMP packet to send.</font></p>
<p><font face="Arial"><strong>Remarks</strong></font></p>
<p><font face="Arial">Internally this function will use the raw winsock 2 calls to do a
ping. To make this function available you will need to define the CPING_USE_WINSOCK2
preprocessor macro and link to the winsock v2 dll, namely ws2_32.lib. Please note that
this dll is only available on NT or recent service packs of Windows 95 and is not
available on the original build of 95, namely build 950.</font></p>
<p> </p>
<p> </p>
<p> </p>
<p><font face="Arial"><big><a name="Enhancements"></a></big><font color="#000000" size="4"><strong>PLANNED
ENHANCEMENTS</strong></font> </font>
<ul>
<li><font face="Arial">Implement a class which builds upon CPing to provide traceroute
capability.</font></li>
<li><font face="Arial">Include a better sample program.</font></li>
<li><font color="#000000" size="3" face="Arial">If you have any other suggested
improvements, please let me know so that I can incorporate them into the next release.</font></li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<p><font face="Arial"><a name="Contact"></a><font color="#000000" size="4"><strong>CONTACTING
THE AUTHOR</strong></font></font></p>
<p><font color="#000000" size="3" face="Arial">PJ Naughter<br>
Email: <a href="mailto:pjn@indigo..ie">pjn@indigo.ie</a><br>
Web: <a href="http://indigo.ie/~pjn">http://indigo.ie/~pjn</a><br>
9th November 1998</font></p>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -