[SOLVED] list of all computers in local network (windows)



  • hello,
    im trying o get a list of all computers in local network. I´m on windows. I cant find a way to do that.
    Any idears?
    Thanks in advance!



  • Hi,
    I'm guessing that you use TCP/IP v4 network as LAN?
    Then this might be something for you:

    Docs: If you pass a literal IP address to name instead of a host name, QHostInfo will search for the domain name for the IP (i.e., QHostInfo will perform a reverse lookup). On success, the resulting QHostInfo will contain both the resolved domain name and IP addresses for the host name. Example:
    @QHostInfo::lookupHost("4.2.2.1",
    this, SLOT(lookedUp(QHostInfo)));@
    Simply loop around every possible IP adres within your LAN and you're done.



  • Hello,
    Thanks for your reply!
    I already tried that already and yes, it works. B U T :
    it is very very slow. i have to wait several minutes until it´s finished.
    it there a faster alternative?



  • Why you don't use the ipscan approach?
    You have to scan each ip of your subnet and, for each ip, look if there are ports open.



  • Here some code:
    I search for every adress in my network.
    do you that mean with ipscan?

    It works, but very very slow.
    it takes minutes!

    QString network = "130.17.40.";

            for(int i=0;i<255;i++)
            {
                QString currIp = (network+"%1").arg(i);
                qDebug() << "CURR IP: " << currIp;
    

    // QHostInfo::lookupHost(currIp,
    // this, SLOT(lookedUp(QHostInfo)));
    QHostInfo HI = QHostInfo::fromName(currIp);
    qDebug() << "NAME: "<< HI.hostName();
    }



  • Please, search for ipscan.exe and look at how this program works.
    You have to use threads to scan fast and simultaneous.



  • ok, thanks.
    I`ll search for this!



  • You might need the QtConcurrent class to handle multiple short threads and add signals if an used IP was found. Then you're able to fast scan all IP's in your LAN.



  • Great! This might be the solution! Thanks!



  • Hi,
    Please place [SOLVED] before your first post. Keeps us from reading unneeded and others for finding a solution to there problem.


Log in to reply
 

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