PDA

View Full Version : Ping a server with Javascript??



locbtran
09-10-2010, 04:28 AM
Is it possible to ping a server from a client to server side. Using Javascript. I checked the web and couldn't find anything.

jscheuer1
09-10-2010, 07:55 AM
Pinging is accomplished at the OS level of the client. This cannot be easily reached by javascript. Active X or Java, perhaps others could theoretically be used. However, since the browser cannot know that all you want is an innocent ping, it will be blocked unless you have a certification. These are generally obtained from a third party, aren't cheap, and require annual maintenance fees. Utilizing them for something like this would add a level of complexity to the script code. They are most often used for e-commerce (https), where their utilization is generally more transparent/intuitive. There are different kinds. What you would need for this is probably different than that for an ssl (https).

You can use javascript to tell the browser to download an image, and even time how long it takes. Divide the number of bytes by the length of time it takes to download it and you can get bps (bytes per second) or bpms (bytes per millisecond), the sort of information that you might want from a ping.

If this is of interest to you, would satisfy your needs here, I can throw together some code for it.

If there's some other information you are after, let me know what it is. There may be a way to get at that as well.