How to ping an ip address and port with Qt



  • How can I ping an i address and port using Qt without using QProcess? I want to know if the ip:port is online and how long (in ms) it takes to respond.


  • Moderators

    This question was already asked recently, please search in the forum.
    As far as I know ping is something special and cannot be done easily (it is not Qt issue).
    Most probably you will have to use QProcess with ping command or something else.
    Depending on what is listening on that IP/port you could send a request and wait for the response and measure the time?



  • @Volebab

    As @jsulm said, its hard to do and it depends on the platform you use. MSDN provides some methods such as IcmpSendEcho but its Windows only (I have never tried that)
    The other way is to do lots of coding ... (using google will result in some stackoverflow postings)


  • Qt Champions 2016

    @Volebab

    How can I ping an i address and port using Qt without using QProcess?

    As @jsulm remarked, you can't. Ping is part of ICMP and is a low-level protocol (under the TCP/IP stack), so it's not accessible through Qt means.

    I want to know if the ip:port is online and how long (in ms) it takes to respond.

    You can try opening the port directly instead. See QTcpSocket or QUdpSocket (depending on the listening application) for inspiration.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.