我需要使用 flash 或 actionscript ping 到网络

发布于 2024-11-05 03:39:58 字数 147 浏览 4 评论 0原文

我用 Flash 创建了一个网络故障排除工具。该设计将在屏幕上显示所有组件。我必须每分钟对每个组件执行一次 ping 操作。我已经完成了设计部分。

请有人帮助我如何 ping 闪存中的网址或 IP。

我需要一个示例代码..我使用 Flash CS3

I have created a network trouble shooting tool in flash. The design will have all the componenets on the screen. I have to ping to every component once in minute. I have finished the design part.

Please someone help me how do i ping a webaddress or IP in flash.

I need a sample code.. Im using Flash CS3

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柠檬色的秋千 2024-11-12 03:39:58

简而言之,你不能。

更长:你将无法 ping,因为 ping 实际上是一个 ICMP 数据包,我不相信 Flash 可以发送这些数据包。如果您尝试 ping 的计算机上正在运行某些 UDP 或 TCP 服务,并且该计算机正在运行 套接字策略服务器,那么您就可以使用 套接字策略服务器。 html">Socket 类直接连接到该服务(其作用类似于 ping)。

In short, you can't.

In longer: you won't be able to ping, because a ping is actually an ICMP packet, and I don't believe Flash can send those. If there is some UDP or TCP service running on the machine you're trying to ping, though, AND the machine is running a socket policy server, then you would be able to use the Socket class to connect directly to that service (which could act like a ping).

肩上的翅膀 2024-11-12 03:39:58

屏幕上显示了所有组件,并且必须每分钟 ping 一次每个组件,这是什么意思?

如果 ping 你指的是一个应用程序,它检查 url 的时间响应,那么你可以尝试使用以下代码:

var ldr:URLLoader = new URLLoader();
ldr.addEventListener(HTTPStatusEvent.HTTP_STATUS, ldrStatus);

var url:String = "URL-TO-SITE";
var limit:int = 10;

var time_start:Number;
var time_stop:Number;
var times:int;

ping();

function ping():void
{
    trace("pinging", url);

    times = 0;
    doThePing();
}

function doThePing():void
{
    time_start = getTimer();
    ldr.load(new URLRequest(url));
}

function ldrStatus(evt:*):void
{
    if(evt.status == 200)
    {
        time_stop = getTimer();
        trace("got response in", time_stop - time_start, "ms");
    }

    times++;
    if(times < limit) doThePing();
}

这没什么特别的,URLLoader 尝试加载 url,并监听到响应。如果status200,则获得成功的“ping”。或者乒乓球。

另一方面,您始终可以运行服务器端 ping 程序,并使用闪存对其进行控制。

如果您指的是一个应用程序,例如上传下载速度测试器,它也以类似的内容开头,但以 Loader 对象。

希望这有帮助。

编辑:

防止缓存问题,您可以使用:

ldr.load(new URLRequest(url + "?rnd="+Math.random()));

现在,此页面可能不会返回站点的确切内容,但可能足以估计响应时间。带闪光灯。

总的来说,这可以清除缓存并每次加载网站以获得更好的结果。

What do you mean by you have all the components on the screen and you have to ping every component once in a minute?

If by ping you mean an app, what checks the time-response of a url, then you can try to play with this code:

var ldr:URLLoader = new URLLoader();
ldr.addEventListener(HTTPStatusEvent.HTTP_STATUS, ldrStatus);

var url:String = "URL-TO-SITE";
var limit:int = 10;

var time_start:Number;
var time_stop:Number;
var times:int;

ping();

function ping():void
{
    trace("pinging", url);

    times = 0;
    doThePing();
}

function doThePing():void
{
    time_start = getTimer();
    ldr.load(new URLRequest(url));
}

function ldrStatus(evt:*):void
{
    if(evt.status == 200)
    {
        time_stop = getTimer();
        trace("got response in", time_stop - time_start, "ms");
    }

    times++;
    if(times < limit) doThePing();
}

This is nothing special, the URLLoader tries to load the url, and listens to the response. If the status is 200, then got a successful "ping". Or pong.

On the other hand, you can always run a server-side ping program, and control that with flash.

If you mean an app, like an upload-download-speedtester, that also starts with something like this, but rather with the Loader object.

Hope this helps.

EDIT:

Preventing cache problems, you can use:

ldr.load(new URLRequest(url + "?rnd="+Math.random()));

Now, this page might not give back the exact content of a site, but might be good enough to estimate the response time. With flash.

So overall, this could clear the cache and load the site everytime to give a better result.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文