Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Find out my ip address on the internet by Qt

Find out my ip address on the internet by Qt

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 1.1k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • thamT Offline
    thamT Offline
    tham
    wrote on last edited by
    #1

    I could get my ip address from this website,is it possible to obtain that address by Qt?

    Would like to create a ftp server and let other's connect to my pc, thanks

    raven-worxR 1 Reply Last reply
    0
    • thamT Offline
      thamT Offline
      tham
      wrote on last edited by
      #2

      What I trying to do is

      server_ = new SslServer(this);   
      server_->listen(QHostAddress::AnyIPv4, port);
      //ftp protocal implementation
      

      Is it possible to listen to the other pc if I give them the address I obtain from the "whatismyipaddress.com"?

      artwawA 1 Reply Last reply
      0
      • thamT tham

        I could get my ip address from this website,is it possible to obtain that address by Qt?

        Would like to create a ftp server and let other's connect to my pc, thanks

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        @tham
        I suggest you use a free (signup required though) Webservice (like ipstack.com) for the sake of simplicity.
        Use QNetworkAccessManager to make a GET request to their API and parse the JSON response with QJsonDocument.

        But note the IP is only required if you want to let the clients connect via internet (assuming port forwarding is correctly setup on your router).

        For your local LAN IP address you can use:

        QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
        for( int i = 0; i < ipAddressesList.size(); ++i ) {
            if( ipAddressesList.at(i) != QHostAddress::LocalHost && ipAddressesList.at(i).toIPv4Address() )
                    qDebug() << ipAddressesList.at(i).toString();
        }
        

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        3
        • M Offline
          M Offline
          mhhorse
          Banned
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • thamT tham

            What I trying to do is

            server_ = new SslServer(this);   
            server_->listen(QHostAddress::AnyIPv4, port);
            //ftp protocal implementation
            

            Is it possible to listen to the other pc if I give them the address I obtain from the "whatismyipaddress.com"?

            artwawA Offline
            artwawA Offline
            artwaw
            wrote on last edited by
            #5

            @tham Hi,
            to add to what @raven-worx said we would need to know more (mainly, as this has been pointed out, are you referring to the public IP address of your Internet node or to the machine assigned local IP?) as use case will differ. Also, additional actions like port forwarding might be required.
            Could you please describe what's your intended use case? How would you like your software to work?

            For more information please re-read.

            Kind Regards,
            Artur

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved