DHCP vs TCP connection
-
QTcpSocket will notify you when the connection is lost. You then need to reconnect.
-
QTcpSocket send a signal when there is an error or the connection state is changed. You can connect your slot to it and react there.
As for the IP: I guess it is only your client that can change the IP, right? The server's IP should remain static. So you need to reconnect from the client to the same address it used in the first place.
If that is not the case, you need to implement some other way of address discovery.
-
How do you connect them in the first place, then? You have to have a way of finding out the IP.
In a single LAN network, you can use simple UDP broadcast messages to help peers automatically discover the server.
Or you could create a local DNS and give your server a name, but that is much harder to do.
-
This is just an UDP ping saying "I'm the server and this is my IP". Once you have it, you can connect securely using TCP like you do right now.
That is just a proven idea, anyway. Feel free to use some other approach if you want to.
-
I all depends on how your network is setup.
There are two way's of protecting that you have the same ip.
- set your ip fix on your network controller.
- make a reservation on your DHCP server.
the difference between TCP an UDP is.
If a TCP packet fails it will be re transmitted on UDP packed it wil be not re transmitted.
-
Hi,
Depending on your setup, use zeroconf might also be a possibility to simplify that task.