0

I have a problem, I need to check the connection between client server, i need to get the response time in ms between the client and a "x" server with php, how I can do that?

Burkhard
  • 14,596
  • 22
  • 87
  • 108
  • possible duplicate http://stackoverflow.com/questions/9841635/how-to-ping-a-server-port-with-php –  Aug 28 '14 at 17:05
  • i have tried that script, but it returns me the response time between my server and the "x" server, i need to check the reponse time bteween the client and other server! – Ryan Connor Aug 28 '14 at 17:08
  • I would here something write with javascript. You start a simple request to a server, and store the local time in miliseconds. After the response you can check how long has it taken. – derdida Aug 28 '14 at 17:11
  • So, what are you asking is client (running the HTML/JS) to request something from another server and get the ms between. Try to make an ajax call from client to X server or to your server, and that server to the X server, then return the ms. –  Aug 28 '14 at 17:13

1 Answers1

1

There are many possible answers to your question. Depending on the answer you will get slightly different results. I have found a jsfiddle that pings servers from Javascript and forked it to include the timing. See:

http://jsfiddle.net/KIKO_Software/x6r4o5hv/1/

The bit that pings is this:

this.img = new Image();
this.img.src = "http://" + ip;

The timing is done like this:

var start = new Date().getTime();
// now do something that takes time here
var finish = new Date().getTime();
var responsetime = 'responded in '+(finish-start)+' ms';

This code needs a lot of work to be useable, but it shows the principle.

KIKO Software
  • 15,283
  • 3
  • 18
  • 33