Hello, the first QT program i'm writing is a NNTP program to post binaries.
Up to now I managed to connect with the server and to read its response to several commands I give (like 'POST' and 'HELP'). So far so good.
Of course I first try to send a small message with only text in the body, and if this works I can focus on sending binaries.

But I have a problem I don't understand ... when I try to send that message I need to do it as in this code:
Qt Code:
  1. QString CRLF("\n");
  2. t.clear();
  3. t.append("From: " + userName + + CRLF);
  4. t.append("Newsgroups: " + (comboBox->currentText()) + CRLF);
  5. /// and so on with a few other commands more
  6.  
  7. tcpSocket->write(t.toAscii().data()); //this writes the data to the socket
To copy to clipboard, switch view to plain text mode 

With this code the server returns a '500', meaning it doesn't understand the commands.

Now I found out that if I remove the 'CRLF' the newsserver doesn't complain but of course nothing is posted. And I know from an existing program the cr/lf must be there. Here's a snippet from that c-program I sometimes use, called 'newspost' (but this text based program is no longer maintained for Linux).

Qt Code:
  1. buff = buff_add(buff, "From: %s\r\n", data->from->data);
  2. buff = buff_add(buff, "Newsgroups: %s\r\n", data->newsgroup->data);
  3. buff = buff_add(buff, "Subject: %s\r\n", subject);
  4. buff = buff_add(buff, "User-Agent: %s\r\n", USER_AGENT);
  5. // and so on ...
To copy to clipboard, switch view to plain text mode 

For the CRLF I tried "\r\n" too ... with the same result.
Here's the routine to read the server, it works without problems.

Qt Code:
  1. void myQtApp::readHost()
  2. {
  3. QMessageBox msgWarn;
  4. s.clear();
  5. t.clear();
  6. s=tcpSocket->readLine();
  7.  
  8. switch(s.left(3).toInt()){
  9. case 100:
  10. t.append("request for help granted");
  11. break;
  12. case 200:
  13. t.append("server ready to receive");
  14. break;
  15. case 211:
  16. t.append("newsgroup valid and selected");
  17. break;
  18. case 221:
  19. t.append("no data follows");
  20. break;
  21. case 340:
  22. postFiles();
  23. break;
  24. case 500:
  25. t.append("wrong command");
  26. break;
  27. case 501:
  28. t.append("wrong syntax after command");
  29. break;
  30. default:
  31. t.append(s.left(3));
  32. // temporarily messageBox for control
  33. msgWarn.warning(this, "server says", s.toAscii().data(), QMessageBox::Ok);
  34. break;
  35. }
  36.  
  37. label_status->setText(t);
  38. }
To copy to clipboard, switch view to plain text mode 

It puzzles me that the server doesn't accept a carriage return ... well, to be honest I do believe it's my code that is in error, not the server. Or is it something with the tcpSocket?
I'm stuck

All info welcome. Thanks in advance for your reply.