bfyviolin
17th February 2011, 22:32
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
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