从 C/C++ 程序 Ping
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6697292/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Pinging from a C/C++ program
提问by Vishal
I want to write a C or C++ program, that given an IP address, Pings it and then performs further action based on whether the Ping was successful or not. How to do this?
我想编写一个 C 或 C++ 程序,给定一个 IP 地址,对其进行 Ping,然后根据 Ping 是否成功执行进一步的操作。这该怎么做?
采纳答案by Nikolai Fetissov
Have a blast at The Ping Page, which has a link to full sourceon the original Unix ping(8)
.
在The Ping Page 玩得开心,那里有原始 Unix 上完整源代码的链接ping(8)
。
回答by T.T.T.
EDITI saw after I posted, you are on Ubuntu. However someone searching this question may still find these links helpful for Windows.
编辑我发帖后看到的,你在 Ubuntu 上。但是,搜索此问题的人可能仍会发现这些链接对 Windows 有帮助。
Ping: Raw Sockets Method: http://tangentsoft.net/wskfaq/examples/rawping.html
Ping:原始套接字方法:http: //tangentsoft.net/wskfaq/examples/rawping.html
Implementing Internet Pings Using Icmp.dll: http://support.microsoft.com/default.aspx?scid=kb;en-us;170591
使用 Icmp.dll 实现 Internet Ping:http: //support.microsoft.com/default.aspx?scid =kb;en-us;170591
IcmpSendEcho Function: http://msdn.microsoft.com/en-us/library/aa366050%28VS.85%29.aspx
IcmpSendEcho 函数:http: //msdn.microsoft.com/en-us/library/aa366050%28VS.85%29.aspx
Ping for Windows: http://www.codeproject.com/KB/IP/winping.aspx
Windows 的 Ping:http: //www.codeproject.com/KB/IP/winping.aspx
回答by David Gatti
This post is old but I think the following link will help future people lookign for a good explanation on how to create a Ping request.
这篇文章很旧,但我认为以下链接将帮助未来的人们寻找有关如何创建 Ping 请求的良好解释。