The problem is that my run function is returning only the first few characters (up until the first whitespace actually) of the data that has arrived on the socket. So it returns

Qt Code:
  1. 200
To copy to clipboard, switch view to plain text mode 

instead of

Qt Code:
  1. 200 newsreader2.eweka.nl NNRP Service Ready - news.eweka.nl (posting ok)
To copy to clipboard, switch view to plain text mode 

Anyone know why? It works fine if I uncomment the readLine() function, but I'm trying to get it to work using a datastream.

Qt Code:
  1. void Connection::run()
  2. {
  3. QTcpSocket socket;
  4. const int Timeout = timeout * 1000;
  5. emit emitData( "run() commencing" );
  6. quit = false;
  7. socket.connectToHost( hostName, port );
  8. if( !socket.waitForConnected( Timeout ) ){
  9. emit emitData( "returning ( socket.waitForConnected )" );
  10. return;
  11. }
  12. while(!quit){
  13. emit emitData( "entering loop" );
  14. if( !socket.waitForReadyRead( Timeout ) ){
  15. emit emitData( "returning ( socket.waitForReadyRead )" );
  16. return;
  17. }
  18. QString data;
  19. QTextStream dataStream( &socket );
  20. // while( socket.canReadLine() ){
  21. // emit emitData( socket.readLine() );
  22. // emit emitData( QString::number( socket.bytesAvailable() ) );
  23. // if( socket.waitForReadyRead( Timeout ) ){
  24. // emit emitData( "returning ( socket.bytesAvailable )" );
  25. // return;
  26. // }
  27. // }
  28. dataStream >> data;
  29. emit emitData( data );
  30. }
  31. }
To copy to clipboard, switch view to plain text mode