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.
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?
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)
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
QUdpSocket(depending on the listening application) for inspiration.