客户端 ping 服务器
我想知道让网站访问者 ping 各种远程服务器的最佳方法是什么。 例子: 我是一名访客,我从 法国巴黎
的一系列位置中进行选择,脚本将从我的位置 ping 到巴黎,并返回平均 x 次 ping 尝试。
有什么想法吗?
I am wondering what would the best way to let visitors of a website ping various remote servers.
Example:
I am a visitor, I choose from a lsit of locations Paris, France
and the script would ping from my location to Paris and return an average of x number of ping attempts.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定是否存在“最佳”方法,但肯定有几种方法可以管理它。
在本地执行
或类似的东西,即ping
命令>exec()exec("ping $stuff",$output);
。这显然会将您与外部程序耦合起来,这可能是不可取的,并且您必须解析输出。听起来您实际上想要的不仅仅是通常的“服务器还活着吗?”类型的支票,所以如果是我,我会选择 PEAR 套餐。它已经内置了一些结果解析。我不是 PEAR 的忠实粉丝,但是重新发明轮子没有意义。
I'm not sure there's a "best" way, but there are definitely a few ways you could manage it.
ping
command locally usingexec()
or something similar, ieexec("ping $stuff",$output);
. This obviously couples you to an external program, which can be undesirable, and you'd have to parse the output.It sounds like you actually want more than just the usual "Is the server alive?" type of check, so if it was me, I'd go with the PEAR package. It's already got some result parsing built in. I'm not a huge fan of PEAR, but there's no point in re-inventing the wheel.