On quinta-feira, 21 de abril de 2016 14:05:52 PDT Alexander Carôt wrote:
> 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.
Hello Alex
You probably mean you've got a v4-mapped IPv6 address, as
::ffff:192.0.2.1
You should code as:
bool ok;
quint32 ipv4 = hostaddr.toIPv4Address(&ok);
if (ok) {
// check my IPv4 ACL
} else if (hostaddr.protocol() == QAbstractSocket::IPv6Protocol) {
// check my IPv6 ACL
} else {
// uh... what?
}
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest