PDA

View Full Version : transfer large files using qsocket



vishesh
2nd March 2007, 14:13
how to transfer large files using QSocket

wysota
2nd March 2007, 14:47
Could you provide any details on what you have already tried to achieve the goal? I believe there are examples bundled with Qt that describe how to use QSocket.

vishesh
2nd March 2007, 15:10
hi,
this is the code for upload a file from client side to server side



/*! Used to upload a file */
void ACMClient::fileUpload(QString &a_fileToSend)
{
QFile l_file(a_fileToSend);

if(l_file.exists())
{
if ( l_file.open(IO_ReadOnly ) )
{
QByteArray l_byteArray = l_file.readAll();

l_byteArray = qCompress(l_byteArray);
QString l_string(l_byteArray);
QString l_byteArraySize;
l_byteArraySize.setNum(l_byteArray.size(),10);

QMessageBox::information(this, "FTP", l_byteArraySize);
m_socket->writeBlock( l_byteArray,l_byteArray.size() );
}
}
}

it can read all bytes but QServer socket read only minimum amount of bytes.
what is solution for read all bytes ?

jacek
2nd March 2007, 15:40
it can read all bytes but QServer socket read only minimum amount of bytes.
How do you read the data on the server? Are you aware that the data might arrive in several chunks that you have to merge?