[SOLVED]How to ping an IP and display the latency ?

0 favourites
  • 3 posts
From the Asset Store
High quality sound effect pack, in the following categories: hand, net slide, racket, table, table slide.
  • Hi, guys i'm working on a small app, and i'd like it to show the latency of a server.

    Is there any way to make construct ping the IP automatically and display it ?

    Or do i have to make C2 execute a bat file with a "/ping xxx.xxx.xx.xxxx" command, make it write the reseult on a .txt and import the .txt into construct ?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • If it´s for a server that you owne, you could make a PHP file that responds an "ok".

    Construct side, you starts a timer when request it. Receiving de "ok", you have the "ping". It´s a "console" ping, but it´s the time that your request took to receive the "ok".

  • no, it's not a server i own, but anyway i found how to do it with the AJAX and NWjs

    for those who could need it, this is how i did :

    1- create a .bat file with the ping and set an output text file "ping xxx.xxx.xx.xxx -n 1 > test.txt"

    (don't forget to add the options you want in the .bat to only write in the .txt the data you want)

    2- import both files in your construct 2 files folder (right click > import files)

    3- add the AJAX object then make an action to create 2 AJAX requests on "Request URL", one for the .bat (batTAG) and another for the .txt (txtTAG)

    4-add an action AJAX request "batTAG" on completed > NWjs run file yourbat.bat

    5-add an action AJAX request "txtTAG" on completed > set text to AJAX.lastdata

    if that's confusing this screenshoot should help:

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)