sksingh73
23rd June 2010, 20:48
i am writing a server-client program. i am passing various messages between them. i am easily able to send qstream data type, but facing problem in sending quint32 data. my function for writing data is
void comn::sendMAC()
{
if(tcpSocket->isOpen())
{
QString str2 = QVariant( calc_mac ).toString(); //calc_mac is quint32
tcpSocket->write(QString(str2 + "\n").toUtf8());
qDebug() << "Sending to server: " << calc_mac;
clienttextEdit->append( "sending: " + str2);
}
}
- with above function, i am converting quint32 into qstring & then sending. but i am again stuck, because at receiver side i want data as quint32 & not qstring.
- there can be 2 solution for this:-
- send data in quint32 form only.
- or if sending in qstring, then convert back into quint32. but how??
-- please help.THANX
void comn::sendMAC()
{
if(tcpSocket->isOpen())
{
QString str2 = QVariant( calc_mac ).toString(); //calc_mac is quint32
tcpSocket->write(QString(str2 + "\n").toUtf8());
qDebug() << "Sending to server: " << calc_mac;
clienttextEdit->append( "sending: " + str2);
}
}
- with above function, i am converting quint32 into qstring & then sending. but i am again stuck, because at receiver side i want data as quint32 & not qstring.
- there can be 2 solution for this:-
- send data in quint32 form only.
- or if sending in qstring, then convert back into quint32. but how??
-- please help.THANX