Hrmmm. Try to pass the socket as a pointer and not as a reference, I
mean:
void MailChecker::writeToSocket( QTcpSocket *socket, const QString &str )
To copy to clipboard, switch view to plain text mode
Using copy constructor you force the creation of a copy object and destruction of it. Passing pointer you don't. I think that in this process, you close the original socket and create a new,disconnected one.
Before doing this change you can try to call state() on the socket to check if it is connected or nor.
I also advice you to use a statement like:
if( waitForBytesWritten(timeOut) ) return 0;
else return -1;
if( waitForBytesWritten(timeOut) ) return 0;
else return -1;
To copy to clipboard, switch view to plain text mode
to control the write event.
Bookmarks