Original Post
🔒 Locked
JavaScript: Pinging A Server
Advertisement
It just might be possible.
Resonable, maybe not, but possible, yes.
What you need to do, is to make a frame, that then connects to your PHP script, which then pings the adress, along with a bit of javascript to get the info back to you.<br><br>From,<br>Nice coder
Resonable, maybe not, but possible, yes.
What you need to do, is to make a frame, that then connects to your PHP script, which then pings the adress, along with a bit of javascript to get the info back to you.<br><br>From,<br>Nice coder
You're not going to be able to do any low-level networking in javascript in a browser. But as Kylotan says, you could use XMLHttpRequest to request a small item from the server and time it. That might do what you want.<br/><br/>Or if you genuinely feel the need to do a ping, you could use a XMLHttpRequest to request a server-side script, which would do a genuine ICMP ping, but from the server. So then the time you get will be not dependent on the time from the client to the target, but the server.<br/><br/>If you're trying to time various servers to determine which one is nearer, the XMLHttpRequest for a small file should do the job. But it's not terribly accurate as it will be affected by other things like network traffic, server load etc. And the time that you get will be for the entire request not just one round trip, so packet loss could increase that considerably (as HTTP uses TCP).<br/><br/>Mark
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement