socket.io ping test

ping.html last modified: February 17 2016 23:48:28 ET

What's the deal?

This page connects to a node server I have running at node.steelcomputers.com that is listening on port 8000 for websocket connections. When you click "PING" it will start a timer and ping the server.

The server will respond back and then a round trip latency is calculated against the previous time. So the latency is the sum of the time to deliver the packet to the server, the server to process / respond to it, and finally the time it takes to be returned. I have found it to show less than 20ms of latency pretty consistently on a low spec server.

Running: Node.js on Ubuntu 12.04.4 LTS on a server I purchased for $35 from cloudatcost

Source Files

Server.js - Node.js script that replies to pings.
ping.html - Client html code that sends pings.

Console Extras

Using the console (F12 in Chrome) you can try playing with socket emit. Make sure to go to the ping.html iframe instead of "Top Frame".

the server will reply with string + "?!?"
socket.emit('msg', 'String here', function (data) {
 console.log("The server says: " + data); // display response from the server.
});

You can have the server run a little script to check for even/odd.
socket.emit('evenOdd', 'String here', function (data) {
 console.log("The server says: " + data); // display response from the server.
});

This page last modified: February 17 2016 23:48:28 ET