PDA

View Full Version : QTcpSocket with QTextStream



Lis
20th August 2010, 08:01
Hello everyone.
I use qt 4.6.3 with visual studio 2010.

I found a smtp class on the net, which I try to modify a little.
Sadly I get the error:
QSocketNotifier: socket notifiers cannot be enabled from another thread
and the conversation with the smtp server stops.

The error is shown after the function sendLine() is called from nextLine().
After that, nothing happens anymore.
Can someone tell me what I am doing wrong?

stmp.cpp:
http://codepad.org/r0RLf1sw

smtp.h:
http://codepad.org/fbAopRXs

Thank you, Louis Hoefler

Lis
20th August 2010, 09:31
I think I found the error, I do execute read and write asynchronously. If the server respondes with a bigger delay, I get errors.

Lis
20th August 2010, 10:14
I solved the „stop conversation“ problem by inserting
a smtpsocket->flush() into the sendLine() function.
The warning about QSocketNotifier does still show up.

Can someone give me a hint what I need to modify to
remove that messages?
Also the smtpsocket->waitForReadyRead(Timeout)
function in run() never returns, only if I change the
Timeout to a value <= 100, why?

Thank you, Louis Hoefler.