How to set IP to client socket



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



  • 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

    Hi,

    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("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());
    }@


  • Lifetime Qt Champion

    Hi and welcome to devnet,

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


Log in to reply
 

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