Results 1 to 2 of 2

Thread: getPeerAddress on localhost ?

  1. #1

    Question getPeerAddress on localhost ?

    Hi
    I encounter a problem when run both client and server on one computer with an IP address 10.0.0.3 acquired by DHCP.
    On the server side, when i call QUdpSocket::getPeerAddress().toString() to get the ip address of client connected, it returns an empty string. Neither 10.0.0.3 nor 127.0.0.1.
    that's why? how can i get the real ip 10.0.0.3?

    code as follows:
    printf("received data from: %s:%u\n",
    qPrintable(udpSocket.peerAddress().toString()), udpSocket.peerPort() );

    the result is:
    received data from: :0

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    5
    Thanked 86 Times in 81 Posts

    Default Re: getPeerAddress on localhost ?

    From Qt docs

    QHostAddress QAbstractSocket:eerAddress () const
    Returns the address of the connected peer if the socket is in ConnectedState; otherwise returns QHostAddress::Null.
    UDP is a Connection-less Protocol
    A camel can go 14 days without drink,
    I can't!!!

Similar Threads

  1. qudpsocket and localhost
    By ih8veggies in forum Newbie
    Replies: 1
    Last Post: 18th February 2011, 14:54
  2. Replies: 0
    Last Post: 3rd December 2008, 12:58
  3. QHttp with localhost.
    By William Wilson in forum Qt Programming
    Replies: 3
    Last Post: 30th June 2007, 21:26

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
  •  
Qt is a trademark of The Qt Company.