[SOLVED] How to obtain the list of computers that are in the local network?
-
The problem is that the code will be integrated in a distributed software. It is why I have written that I know nothing about the network. Even, this network may not exist (stand-alone computer). So, what I need is to do something equivalent to "Network" that we find on Windows Platforms. And this is I do not know to do with QT.
-
The "Network" is based on NetBIOS which is a windows only feature. You can work with it when you use samba. Maybe you can resolve this task with "nmap":http://nmap.org/.
nmap should work under windows, linux and Mac.
-
In general there is no reliable way to find all hosts on an IP network. ping, nmap, etc. all should get most hosts, but not necessarily all of them and produce a lot of packets to generate their list. This list will then contain all (discovered) hosts on your network, which is usually not what you want: Generally you only care about the hosts that actually offer some service, and not about smart phones that happen to hang in your wlan.
You might want to look into mDNS, bonjour, avahi (different names for the same thing), which allows hosts to advertise their services on the local network and other hosts to discover them.
-
Hi Tobias,
What I want is exactly this: discover a set of hosts. Discovering also smartphones that are connected to the network is not a problem. Because I do not need to obtain services from the hosts. I just need to be able to read folders. But I cannot expect that the network be configured using a tool like mDNS. Moreover our software is not for computer specialists. Hence the networks will probably have a "basic (automatic) configuration". -
In that case I would do it the other way around.
Every computer which has a public folder has to register to the server with your software.
The network administrator as to send e.g. an email to all users how are responsible to the computer in the network to register to this service. Then you can run your software.The other way around that the server searches trough a unknown network is very complex because there are so many possibilities that a testing of your software is impossible.
-
Hi Juergen,
I am just pretty sure that, if customers have to make something so that their computer being seen by my software, they will not do it. In this case it is more simple to force the user of the software to map remote folder to have access to them, or to list them manually.So, for the first version, as it seems that QT cannot answer to my problem, I think that I will use Windows functions. This means that my software will only be able to work on Windows OS or equivalent (virtual machines on Mac). This limitation might be OK for the initial version of the software. And for the next versions I will have to investigate more about other solutions.
-
Hi Alain, your problem is not a Qt problem.* It is a network problem.*
I'm not quite sure but even when you are concentrating on Windows platforms it will not automatically solve your problem. Your customer would need a WINS/NetBIOS server installed to find all computers in the unknown network of your customers. And that is definitely not guaranteed.
-
Yes it si a "network problem". But, as QT has a network module I expected to be able to find a solution using it. For the presence of NetBIOS server, if a standard Windows explorer (when application runs on Windows OS) cannot see the remote computers, my application does not have to see them.
For my software I just need to offer, using a QTreeView, a similar view of what is it seen using QFileDialog::getExistingDirectories. Hence, if a computer needs to be "mounted" to be seen (UNIX case) I just need to show monted computers. And if it needs a NetBIOS server to be seen, I just need to show computers known by this server.
-
Not correctly. First you have to understand the possibilities how to detect computers in a network for each OS. You have to know the advantages and disadvantages of each solution. Create a document and a solution/choose matrix. Then create a realization plan and try to realize a first solution e.g. discovery method for Windows.
If your software is important for your customers you can also add some install requirements e.g. mDNS
And so on.
-
"Reading a folder" is done by a service running on a host, so you are interested in service discovery.
Assuming that you are interested in folders shared by windows machines you could read up on the protocols involved... or just use the windows APIs for discovering them directly (assuming you do not care for non-windows platforms running your application).
-
[quote author="Alain38" date="1370416822"]OK. Finally I do not use QT. I directly use Windows functions. This will be a limitation for the application. But a test on a Mac with parallel desktop shown that these functions also work on Mac.[/quote]
Excuse me, could you say what exactly you've used?