I have a problem with QTcpSocket and Connect()!
-
@xmaze said:
Why you are using Thread ?
Look this example http://doc.qt.io/qt-5/qtnetwork-fortuneclient-example.html -
You may be hitting the even processing issue as signal/slots across thread works using events. Try moving the QTCP Socket object creation to new thread. Don't create the object in constructor. Another suggestion is that you work with single thread and see whether your idea works.
-
You may be hitting the even processing issue as signal/slots across thread works using events. Try moving the QTCP Socket object creation to new thread. Don't create the object in constructor. Another suggestion is that you work with single thread and see whether your idea works.
@dheerendra can you be more clear? i cannot understand your suggestion! Thank you
-
And forgot ! Of course you need to call readAll insted read. Because if new data will not send to socket - signal readyRead will never be emited ! And data will be lost
@jalomic But with ReadAll i cannot use pointers to manipulate the position of the buffer, so i cannot write the data and the end of the buffer ?
An other problem is that ReadAll needs a QbyteArray and this make the work complicated because i need the pointers and with QbyteArray is a class... -
@jalomic But with ReadAll i cannot use pointers to manipulate the position of the buffer, so i cannot write the data and the end of the buffer ?
An other problem is that ReadAll needs a QbyteArray and this make the work complicated because i need the pointers and with QbyteArray is a class... -
@xmaze
Oh
QByteArray array = socket ->readAll();
memcpy(BUFFER+p,array.data(),array.size())
p+=array.size();