PDA

View Full Version : QHostInfo usefullness



baray98
15th December 2007, 01:32
Guys,

I have an app that is an interface to an electronic system and the connection between the system and my app is through ethernet using TCP/IP style and trough a network. My app would be responsible for assingning the IP address to the system that its currently talking to trough an RS232 link which a default connection when a system boots up.

Anyways, my question is that how can i make sure that an IP address is free ( or no conflict in the network). My plan is to use QHostInfo (I will keep a list of addresses that i have to check ) and keep trying to QHostInfo::lookUpHost(mylistofipaddress) and if no error returned then i would mark that address as taken. Is there any other easy way to do this?

baray98

marcel
15th December 2007, 07:26
It could take some time to test all the addresses...
Can't you just let the user input the IP he/she wants for the system?

baray98
15th December 2007, 07:53
I guess i could but the problem would be if the address is used by the other system so when my app runs it will ping two systems...and so there will be confusion.

baray98

marcel
15th December 2007, 09:13
I guess i could but the problem would be if the address is used by the other system so when my app runs it will ping two systems...and so there will be confusion.

baray98
Oh, so your application will be run by plain users... In this case you can go with your solution and add a non-finishing progress bar, so the user sees something while the IP's are being looked up.

wysota
15th December 2007, 14:07
I guess i could but the problem would be if the address is used by the other system so when my app runs it will ping two systems...and so there will be confusion.

Why not keep a shared database of addresses which are currently used in the network and just ask the database for an unused address? That's how dhcp servers work.