PDA

View Full Version : How can I connect client to server without knowing there IP's?



mismael85
29th May 2011, 13:22
Hi Everybody,

How can I connect Client and server without knowing there IP's?

squidge
29th May 2011, 19:21
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?

Santosh Reddy
29th May 2011, 20:33
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

Markus_AC
17th October 2011, 09:32
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?

Markus_AC
17th October 2011, 14:58
I figured out tzhe answer to my qustion #3:



QHostAddress sender;
quint16 senderPort;

udpSocket->readDatagram(datagram.data(), datagram.size(), &sender, &senderPort);


But still I don't know what to do with my qustions #1 and #2.

Can someone help?