ada10
16th August 2010, 12:39
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 -
QFile htmlfile("c:\\server_files\\ywr.mp3");
if (!htmlfile.open(QIODevice::ReadOnly))
return;
QTextStream os( clientSocket );
//os.setAutoDetectUnicode(true);
os << "HTTP/1.0 200 Ok\r\n"
"Content-Type: audio/mpeg; charset=\"utf-8\"\r\n"
"\r\n";
os.flush();
// Streaming the file
QByteArray block = htmlfile.readAll();
clientSocket->write(block);
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 ?
QFile htmlfile("c:\\server_files\\ywr.mp3");
if (!htmlfile.open(QIODevice::ReadOnly))
return;
QTextStream os( clientSocket );
//os.setAutoDetectUnicode(true);
os << "HTTP/1.0 200 Ok\r\n"
"Content-Type: audio/mpeg; charset=\"utf-8\"\r\n"
"\r\n";
os.flush();
// Streaming the file
QByteArray block = htmlfile.readAll();
clientSocket->write(block);
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 ?