PDA

View Full Version : QTcpSocket: crash on write



valerianst
16th May 2014, 13:28
Hi everybody,


I'm sometimes experiencing crashes on this function: qint64 QIODevice::write ( const QByteArray & byteArray );

I am just using QTcpSocket and I am also checking that the QTcpSocket instance has the connected status before writing.

I am not calling the flush method.


Edit:
I'm using this socket in two threads, one receives data from a server, the other sends data to this server.

Cheers!

anda_skoa
16th May 2014, 15:34
I'm using this socket in two threads, one receives data from a server, the other sends data to this server.


This is most likely the problem, just don' do that.

Cheers,
_

valerianst
16th May 2014, 16:35
thanks for your suggestion.

Are the write and QTcpSocket methods in general safe?

Added after 6 minutes:

Just answered by myself. QObject is not thread safe so I guess QTcpSocket isn't either.

I would like to avoid using mutexes in this case but I guess I have to