Important: Please read the Qt Code of Conduct -

I can not receive simple int values over a socket

  • Hi,
    I use a tcp socket with a signal slot mechanism to send and receive messages from a java socket server.
    My problem is the function readReady will just called if I send a string. But I want to send and receive an int.
    Is there an way to do it? Or can i just receive strings?

    My code:

    void TcpSocketCon::readReady()
        qDebug()<<"Read from Socket";

  • In which way is your int send?
    If it is sent binary, you will have to extract it from your buffer. There is no automatic conversion. With QByteArray you may use toInt() However, you need to know the information type to be received.

Log in to reply