I can not receive simple int values over a socket
General and Desktop
2
Posts
2
Posters
471
Views
1
Watching
-
wrote on 19 Mar 2015, 18:18 last edited by tekojo
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:
connect(socket,SIGNAL(readyRead()),this,SLOT(readReady())); void TcpSocketCon::readReady() { qDebug()<<"Read from Socket"; qDebug()<<socket->readAll(); }
-
wrote on 19 Mar 2015, 19:09 last edited by
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.
1/2