How to get LAN ip Address



  • Hi,

    I am using the following code to get the ip address
    @
    foreach (const QHostAddress &address, QNetworkInterface::allAddresses())
    {
    if (address.protocol() == QAbstractSocket::IPv4Protocol && address != QHostAddress(QHostAddress::LocalHost))
    {
    qDebug() << address.toString();
    IpAddr = address.toString();
    }
    }
    @
    I am connected with lan and Wlan both , so it displays 2 address. Can you please let me know how to distinguish between LAn and Wlan?

    Regards,
    Prankur

    [[marked up code, Tobias]]


  • Moderators

    You can not do that based on the IP address.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.