how to check computer's state using Qt?

前端 未结 3 1018
情歌与酒
情歌与酒 2020-12-12 00:30

i\'m trying to get computer\'s state in my LAN... thought about using QTcpSocket but it\'s not realy effective since port also should be inserted as:

socket-         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-12 01:08

    One good way is just to verify that they can resolve domain names using QHostInfo. If they can then they likely have internet access:

    QHostInfo::lookupHost("www.kde.org", this, SLOT(lookedUp(QHostInfo)));
    

    Of course, you could just try to connect to the host as well, which is even better proof that everything is working correctly. I would do it asynchronously rather than synchronously, but it's truly the best test.

提交回复
热议问题