System.Net.NetworkInformation.Ping +仅一次还是两次? [英] System.Net.NetworkInformation.Ping + once or twice only?

查看:93
本文介绍了System.Net.NetworkInformation.Ping +仅一次还是两次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想知道是否有一种方法可以仅一次或两次对IP进行ping操作,而不是在DOS窗口中可以看到的标准4次尝试.

我假设System.Net.NetworkInformation.Ping类的Send(IP)方法的Status结果在4次尝试之后就被检索到.

如果这是错误的,并且仅执行一次ping尝试,我如何为此设置超时时间?

该使用仅限于Intranet,并且响应时间应在毫秒内.

非常感谢您的时间和帮助.

Alex.

Hello everybody,

I was wondering if there is a way to ping an IP only once or twice instead of the standard 4 attempts we can see at the DOS window.

I am assuming that the Status result of the Send(IP) method of the System.Net.NetworkInformation.Ping class is retrieved after 4 attempts.

If this is wrong, and only one ping attempt is performed, how could I set the time out for this?

The use is restricted to an intranet, and response time should be within milliseconds.

Thank you very much for your time and help.

Alex.

推荐答案

您在说什么? System.Net.NetworkInformation.Ping.Send方法,如果重载具有timeout参数,则有些方法.另请参见这些方法的帮助和System.Net.NetworkInformation.PingOptions.谁告诉你一次ping是重复4次?您见过这些课程的帮助吗?

请理解:使用较小的超时会增加误报的可能性.互联网本质上是不确定的.

—SA
What are you talking about? System.Net.NetworkInformation.Ping.Send methods, some if the overloads have timeout parameters. See also help of these methods and System.Net.NetworkInformation.PingOptions. Who told you a ping is repeated 4 times? Did you ever see the help on these classes?

Please understand: using smaller timeouts will increase the probability of false negatives. Internet is non-deterministic by its nature.

—SA


这篇关于System.Net.NetworkInformation.Ping +仅一次还是两次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆