How do I ping from Flex - AIR?

2019-04-09 00:53发布

问题:

I'm bored cause my development server is down and I'm running the command prompt to ping the server indefinitely so that I'll see when they stop timing out and know that I can work again. In the meantime I wanted to make an Air app that will do this for me, so I can have it chirp or alarm or do something when it starts to be able to connect to the server.

So I need to start with having AIR do the ping, does anyone know how to do this? I can't find any help on it. I can't use the HTTPService because whatever it is that is broken (think it's the VPN), our dev web site is still up.

Thanks

回答1:

Otherwise you can use the NativeProcess class of the AIR 2.0 beta, and use the ping command of your operating system.

You can find informations on how to use it here.



回答2:

According to the docs, SocketMonitor, descending from ServiceMonitor will check basic availability, but not a true ping. If you want to truly "ping" the server, you would need to use a socket an implement the protocol, This link to the Wikipedia article might help.



回答3:

The AIR SDK offers some classes (URLMonitor, SocketMonitor) to handle this:

http://livedocs.adobe.com/flex/3/html/help.html?content=network_connectivity_1.html