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. How to set IP to client socket

How to set IP to client socket

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 3.0k Views
  • 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.
  • JulianJ Offline
    JulianJ Offline
    Julian
    wrote on last edited by
    #1

    I'm having problem to set the socket's ip.


    client= new QTcpSocket (this);

    client->connectToHost ("10.0.0.3", 0);


    That's what I had do. The thinks here it's that 10.0.0.3 is a ip which there is in a local connection. What's I'm doing wrong?

    Thanks!

    1 Reply Last reply
    0
    • P Offline
      P Offline
      primem0ver
      wrote on last edited by
      #2

      It is really difficult to understand what the problem is that you are describing because you really haven't described a problem. You also haven't explained what you are trying to do. Are you trying unsuccessfully to connect to a computer with that address? Are you trying (unsuccessfully) to connect a computer at that address to the internet? Any IP address that starts with 10 is a local IP address. (10.x.y.z = local address). There is absolutely no way to change that because it is a standard (I believe it was started with Novel).

      1 Reply Last reply
      0
      • JulianJ Offline
        JulianJ Offline
        Julian
        wrote on last edited by
        #3

        Yes, the connection is unsuccessful. There is a code which I can follow?

        The question was If I can pass on an Ip on that way.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Did you connect the error signal ? If not, do it, it should give you a useful hit about why it's not working.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • C Offline
            C Offline
            Colocolo
            wrote on last edited by
            #5

            I have the same problem. I also want to do a "Client-Server" TCP-IP communication on Embedded platform. IP of device that I know, but I don't know how to set IP for my board (I use Qt for coding).
            @mSocket ->connectToHost("10.0.0.8",11100); //IP and port number of server
            if(mSocket->waitForConnected(1000))
            {
            QMessageBox::information(this,"Server","Connected!");
            }
            else
            {
            QMessageBox::critical(this,"Error",mSocket->errorString());
            }@

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi and welcome to devnet,

              What do you mean by "set IP for my board" ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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