Hello Thiago, Hello Benjamin, thanks for your replies !
In fact Thiago was precisely right with this: > You probably mean you've got a v4-mapped IPv6 address, as > ::ffff:192.0.2.1 As a quick hack I first converted this to a string and removed the first 7 characters but of course Thiagos solution is the way to do it. It works well - thanks a lot, best regards Alex -- http://www.carot.de Email : alexan...@carot.de Tel.: +49 (0)177 5719797 > Gesendet: Donnerstag, 21. April 2016 um 19:02 Uhr > Von: "Thiago Macieira" <thiago.macie...@intel.com> > An: interest@qt-project.org > Betreff: Re: [Interest] Convert IPv6 to IPv4 ? > > 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 > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest