I am trying write a server application which reads an mp3 file on the file system & sends it to a client app through QTcpSocket using the following code -

Qt Code:
  1. QFile htmlfile("c:\\server_files\\ywr.mp3");
  2. if (!htmlfile.open(QIODevice::ReadOnly))
  3. return;
  4.  
  5. QTextStream os( clientSocket );
  6. //os.setAutoDetectUnicode(true);
  7. os << "HTTP/1.0 200 Ok\r\n"
  8. "Content-Type: audio/mpeg; charset=\"utf-8\"\r\n"
  9. "\r\n";
  10. os.flush();
  11.  
  12. // Streaming the file
  13. QByteArray block = htmlfile.readAll();
  14. clientSocket->write(block);
To copy to clipboard, switch view to plain text mode 

The server application crashes when this code is executed. What is the problem in the above code ? Is the method of reading the mp3 file faulty ?