从浏览器Ping [英] Ping from browser

查看:650
本文介绍了从浏览器Ping的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要测试ping的HTML页面. 我希望用户连接到该网站,并在主页上获得从计算机到特定服务器的往返结果.

I have an HTML page which I want to test a ping from. I want a user to connect to the website and in the main page he will get a result of the round trip from his computer to a specific server.

我应该使用"Ping"吗? 我听说过一种叫做适用ping的东西,但这是我需要建立自己的东西,我不知道该怎么做. 请帮助

Should I use "Ping"? I heard about something called applicable ping but it's something that I need to build myself and I don't know how.. Please help

推荐答案

Ping只是请求和响应之间的延迟度量.正如Havenard所说,虽然ping实际上是基于ICMP的,但是您可以使用HTML/JS进行模拟,但是由于处理水平较高,它会增加一些延迟.

Ping is just the measure of delay between a request and response. Though ping is realybased on ICMP as stated by Havenard, you can simulate this using HTML/JS but it will add a bit of delay because of processing in the high levels.


ping-server.html(服务器端)


ping-server.html (Server side)

hello


ping-client.html(客户端/在使用jQuery/js的浏览器中)


ping-client.html (Client side/In the browser using jQuery/js)

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
    var ping = new Date;

    $.ajax({
        url: "ping-server.html",
        cache:false,
        success: function(output){ 
            ping = new Date - ping;
            Console.log("Ping/Latency: " + ping);
        }
    });
</script>
</head>
</html>

这篇关于从浏览器Ping的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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