我在程序中为2个user建立了TCP连接,然后开始传文件;
发送方是每次写100kb,接收方是readall;
对于小文件,如100M,50M等可以很好的传送与接收,但是到了700M,反应的时间就很慢了,不过传输速度没变;1G的时候就传不了了;
这是为什么。。。
发送方写文件的代码如下:
if (!file->open(QIODevice::ReadOnly)) {
cerr << "Unable to read the file" << endl;
delete file;
file = 0;
return;
}
qint64 x,z;
qint64 y=100*1024;
x=file->size();
qDebug()<<"x="<<x;
while(x!=0)
{
if(x<y)
z=x;
else
z=y;
client.write(file->read(z));
x=x-z;
}