Hi Alexander, First there is no way to convert an IPv6 to an IPv4. A given machine can have an IPv6 address without an IPv4 address, or have an IPv4 address without an IPv6 address, or one of each, or many addresses of each type.
If you want peerAddress() to only return IPv4 addresses you must ensure that you cannot be joined with an IPv6 address. One solution, if you are using an QWebSocketServer, is that when you process new connections (i.e when you call nextPendingConnection()) you reject them is the peer address is an IPv6 address. The fallback might be that if a client tries to contact your server through IPv6 first, it might not try IPv4 next and believe that your server is not available. Another solution is to remove the AAAA field from your DNS record (if applicable), but it might make collateral damages if you have multiple applications running on same server. My advice on this is that you should not require IPv4 addresses but must handles both. Especially if your application is going to be used for a long time. Regards, Benjamin 2016-04-21 14:05 GMT+02:00 "Alexander Carôt" <[email protected]>: > Hello, > > I noticed that retrieving a sender's IP address of a QWebSocket via > ->peerAddress() returns an IPv6 socket address. > > For certain reasons I need an IPv4 address so I wonder how it is possible to > either let ->peerAddress() return an IPv4 address or convert the IPv6 address > to an IPv4 address. > > Thanks in advance, > best > > Alex > > -- > http://www.carot.de > Email : [email protected] > Tel.: +49 (0)177 5719797 > _______________________________________________ > Interest mailing list > [email protected] > http://lists.qt-project.org/mailman/listinfo/interest _______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
