Question

I use QTcpServer from the Qt-Framework with C++.

I started it with

ret = tcpServer->listen(QHostAddress::Any, 9871)

With

QHostAddress serverAddress () const

I retrieve the Address from it. Which is 0.0.0.0. In my opinion it should listen on more than one address (like 127.0.0.1 and the LAN Address).

Is there a way to retrieve more than one address from this class?

Was it helpful?

Solution

I'm not sure what your question is exactly, but...

Usually, a 0.0.0.0 means that the socket listen to all interfaces that are both up and configured with a valid IPv4 address.

If you want to get all the available IP addresses on the system, you should enumerate the network interface then query their respective IPv4 address (Probably with an ioctl, specifying SIOCGIFSWADDR).

OTHER TIPS

I agree with ereOn's answer above.

If you want to list your network interface adresses, take a look at QNetworkInterface.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top