惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - 谁是菜鸟?

mysql数据区分大小写 css hack java 乱码 panic user 44/45 Lock wait timeout exceeded; try restarting transaction window.onbeforeunload(支持firefox,ie,Safari) 配置SFS2.x的调试环境 mysql异常处理 常用linux命令 x86_64-unknown-linux - 谁是菜鸟? - 博客园 mysql 动态sql memcached资料 mysql roll back 为没有自动增长列的表添加自动增长列并更新现有数据 SmartFox Server 控制pubMsg - 谁是菜鸟? mysql 命令 java.util.ConcurrentModificationException RenRen应用接入样例 - 谁是菜鸟? - 博客园 jxl read and write excel
js ping - 谁是菜鸟? - 博客园
谁是菜鸟? · 2010-06-03 · via 博客园 - 谁是菜鸟?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>HTTP Ping</title> 
<style> 
html  
{  
    height: 100%;  
    overflow: hidden;  
}  
 
body  
{  
    background: #000;  
    color: #C0C0C0;  
    font-weight: bold;  
    font-size: 14px;  
    font-family: Lucida Console;  
    height: 100%;  
    margin: 0 0 0 5px;  
}  
 
#divInput  
{  
    height: 10%;  
}  
 
#divContent  
{  
    height: 90%;  
    overflow: auto;  
}  
 
#txtTimeout  
{  
    width: 40px;  
}  
 
button  
{  
    margin-left: 10px;  
}  
</style> 
</head> 
 
<body> 
 
<div id="divInput"> 
    <span>URL:</span> 
    <input id="txtURL" type="text" /> 
    <span>Timeout:</span> 
    <input id="txtTimeout" type="text" value="2000" /> 
    <input id="btnSwitch" type="button" value="Start" onclick="handleBtnClick()" /> 
    <hr/> 
</div> 
<div id="divContent"></div> 
 
<script> 
var intStartTime;  
var objIMG = new Image();  
 
 
objIMG.onload =  
objIMG.onerror =   
function()  
{  
    /*  
     * 有回应,取消超时计时  
     */  
    clearTimeout(intTimerID);  
 
    if(!bolIsRunning || bolIsTimeout)  
        return;  
 
    var delay = new Date() - intStartTime;  
 
    println("Reply from " +  
            strURL +  
            " time" +  
            ((delay<1)?("<1"):("="+delay)) +  
            "ms");  
    arrDelays.push(delay);  
 
    /*  
     * 每次请求间隔限制在1秒以上  
     */  
    setTimeout(ping, delay<1000?(1000-delay):1000);  
}  
 
function ping()  
{  
    /*  
     * 发送请求  
     */  
    intStartTime = +new Date();  
    intSent++;  
 
    objIMG.src = strURL + "/" + intStartTime;  
    bolIsTimeout = false;  
 
    /*  
     * 超时计时  
     */  
    intTimerID = setTimeout(timeout, intTimeout);  
}  
 
function timeout()  
{  
    if(!bolIsRunning)  
        return;  
 
    bolIsTimeout = true;  
    objIMG.src = "X:\\";  
 
    println("Request timed out.");  
    ping();  
}  
</script> 
 
 
<script> 
var $ = function(v){return document.getElementById(v)};  
 
var arrDelays = [];  
var intSent;  
 
var bolIsRunning = false;  
var bolIsTimeout;  
var strURL;  
var intTimeout;  
var intTimerID;  
 
var objBtn = $("btnSwitch");  
var objContent = $("divContent");  
var objTxtURL = $("txtURL");  
 
objTxtURL.value = window.location.host;  
 
function handleBtnClick()  
{  
    if(bolIsRunning)  
    {  
        /*  
         * 停止  
         */  
        var intRecv = arrDelays.length;  
        var intLost = intSent-intRecv;  
        var sum = 0;  
 
        for(var i=0; i<intRecv; i++)  
            sum += arrDelays[i];  
 
        objBtn.value = "Start";  
        bolIsRunning = false;  
 
        /*  
         * 统计结果  
         */  
        println(" ");  
        println("Ping statistics for " + strURL + ":");  
        println("  Packets: Sent = " +  
                intSent +  
                ", Received = " +  
                intRecv +  
                ", Lost = " +  
                intLost +  
                " (" +  
                Math.floor(intLost / intSent * 100) +  
                "% loss),");  
 
        if(intRecv == 0)  
            return;  
 
        println("Approximate round trip times in milli-seconds:");  
        println("  Minimum = " +  
                Math.min.apply(this, arrDelays) +  
                "ms, Maximum = " +  
                Math.max.apply(this, arrDelays) +  
                "ms, Average = " +  
                Math.floor(sum/intRecv) +  
                "ms");  
    }  
    else  
    {  
        /*  
         * 开始  
         */  
        strURL = objTxtURL.value;  
 
        if(strURL.length == 0)  
            return;  
 
        if(strURL.substring(0,7).toLowerCase() != "http://")  
            strURL = "http://" + strURL;  
 
        intTimeout = parseInt($("txtTimeout").value, 10);  
        if(isNaN(intTimeout))  
            intTimeout = 2000;  
        if(intTimeout < 1000)  
            intTimeout = 1000;  
 
        objBtn.value = "Stop ";  
        bolIsRunning = true;  
 
        arrDelays = [];  
        intSent = 0;  
 
        cls();  
        println("Pinging " + strURL + ":");  
        println(" ");  
        ping();  
    }  
}  
 
function println(str)  
{  
    var objDIV = document.createElement("div");  
 
    if(objDIV.innerText != null)  
        objDIV.innerText = str;  
    else  
        objDIV.textContent = str;  
 
    objContent.appendChild(objDIV);  
    objContent.scrollTop = objContent.scrollHeight;  
}  
 
function cls()  
{  
    objContent.innerHTML = "";  
}  
</script> 
</body> 
</html>