PDA

View Full Version : Send TCP message



^NyAw^
4th June 2008, 16:17
Hi,

I'm trying to send a message through a TCP socket. The message contains numbers:



char* pacDades = new char[50];
int iLong = 25;
pacData[0] = (char)iLong;
pacData[1] = '$';
pacData[2] = '0';
pacData[3] = '$';
quint16 qNum = 150;
quint8 qNumFotosMSB = (qNum >> 8);
qNumMSB += 48;
quint8 qNumFotosLSB = qNum;
qNumLSB += 48;
pacData[4] = (char)qNumMSB;
pacData[5] = (char)qNumLSB;

qint64 qNumBytes = m_qSocket.write(pacData,qLong);


When I recive the data,


qNumImatgesLSB = qTextos.at(1).at(1).toAscii();


"qNumImatgesLSB" is -58 instead of 150.

What I'm doing wrong?

Thanks,

jacek
4th June 2008, 21:12
What's the difference between qNumLSB and qNumFotosLSB?

^NyAw^
5th June 2008, 09:33
Hi,

Sorry, I have not changed all the variable names:
qNumFotosMSB is qNumMSB
qNumFotosLSB is qNumLSB

I have solved this. The problem was on the variable definition on the reciver. I was using a qint16 instead of quin8.