PDA

View Full Version : getting IP-address



jefklak
22nd October 2010, 20:43
Hey,

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



sock = new QUdpSocket(this);
sock->bind(QHostAddress("192.168.1.5"), 9998);
connect(sock, SIGNAL(readyRead()), this, SLOT(processMessage()));
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.

squidge
22nd October 2010, 21:39
Why use the correct one? Just use '0.0.0.0' which will work on any PC.

jefklak
23rd October 2010, 10:19
it is working. Thanks. I tried this first, but I think that something else would have been the problem.