Hi Everybody,
How can I connect Client and server without knowing there IP's?
Hi Everybody,
How can I connect Client and server without knowing there IP's?
You could send a broadcast UDP packet from the client which the server answers with it's IP address and port number? Or perhaps the server connects to the client once it received such a packet?
No, you cannot connect without knowing IP and port. What you can do is to find out a way to know the Server IP, either use DNS, or broadcast to find out IP
That thread exactly meets my qustions. Thanks, as far. But three further questions:
1) Is it possible to open a QUdpSocket (for Broadcasting and searching for new devices) as well as aQTcpSocket (for data exchange)?
2) In my system I have two network interfaces. How do I select the broadcast for just one interface?
3) How do get the IP-Adress of the sender, when I have received a broadcast message?
Last edited by Markus_AC; 17th October 2011 at 10:24.
I figured out tzhe answer to my qustion #3:
Qt Code:
QHostAddress sender; quint16 senderPort; udpSocket->readDatagram(datagram.data(), datagram.size(), &sender, &senderPort);To copy to clipboard, switch view to plain text mode
But still I don't know what to do with my qustions #1 and #2.
Can someone help?
Bookmarks