Important: Please read the Qt Code of Conduct -

How to set IP to client socket

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

    client= new QTcpSocket (this);

    client->connectToHost ("", 0);

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


  • 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).

  • 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.

  • Lifetime Qt Champion


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

  • 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("",11100); //IP and port number of server

  • Lifetime Qt Champion

    Hi and welcome to devnet,

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

Log in to reply