Results 1 to 3 of 3

Thread: getting IP-address

  1. #1
    Join Date
    Oct 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default getting IP-address

    Hey,

    I want to use Qt to set up a connection over LAN using UDP. I do this using following code:

    Qt Code:
    1. sock = new QUdpSocket(this);
    2. sock->bind(QHostAddress("192.168.1.5"), 9998);
    3. connect(sock, SIGNAL(readyRead()), this, SLOT(processMessage()));
    To copy to clipboard, switch view to plain text mode 
    This way I have to enter my IP-address manually, which isn't nice off course. How can I get the correct IP-address dynamically?

    I am using Qt 4.7.0 in Windows.

  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: getting IP-address

    Why use the correct one? Just use '0.0.0.0' which will work on any PC.

  3. #3
    Join Date
    Oct 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: getting IP-address

    it is working. Thanks. I tried this first, but I think that something else would have been the problem.

Similar Threads

  1. how can i get IP address
    By dognzhe in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2009, 05:27
  2. Get current ip address
    By Trok in forum Qt Programming
    Replies: 5
    Last Post: 16th March 2009, 23:08
  3. IP address find
    By kpmsivachand in forum Qt Programming
    Replies: 6
    Last Post: 21st February 2009, 18:11
  4. IP Address
    By rajveer in forum Qt Programming
    Replies: 2
    Last Post: 11th November 2008, 08:30
  5. validation on an IP address
    By rajveer in forum Qt Programming
    Replies: 15
    Last Post: 24th August 2008, 00:35

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.