Results 1 to 5 of 5

Thread: How can I connect client to server without knowing there IP's?

  1. #1
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Question How can I connect client to server without knowing there IP's?

    Hi Everybody,

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

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can I connect client to 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?

  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: How can I connect client to server without knowing there IP's?

    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

  4. #4
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    27
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I connect client to server without knowing there IP's?

    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.

  5. #5
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    27
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I connect client to server without knowing there IP's?

    I figured out tzhe answer to my qustion #3:

    Qt Code:
    1. QHostAddress sender;
    2. quint16 senderPort;
    3.  
    4. 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?

Similar Threads

  1. Connect push button in server client mode
    By onlybilal in forum Qt Programming
    Replies: 1
    Last Post: 26th May 2011, 17:29
  2. TCP Client / Server
    By bmarsden in forum Qt Programming
    Replies: 4
    Last Post: 8th October 2010, 10:18
  3. How to automaticaly connect client to server
    By sksingh73 in forum Newbie
    Replies: 1
    Last Post: 4th July 2010, 20:08
  4. tcp QT server - .Net c# client
    By soniaerm in forum Qt Programming
    Replies: 0
    Last Post: 21st April 2010, 22:15
  5. client-server how?
    By nongentesimus in forum Newbie
    Replies: 6
    Last Post: 28th November 2006, 09:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.