【发布时间】:2015-01-30 23:44:02
【问题描述】:
我正在编写一个将使用此方法的文件传输协议:
- 客户端以 1024 字节的块发送二进制文件
- 服务器将接收这些块并将它们连接到一个对象中
- 当对象大小变为 100 MB 或更大时,它将被写入磁盘(在新线程中)。
我猜这样做会减少磁盘写入开销,最终会减少发送时间。
我需要一种方法来连接connection.recv() 收到的数据包并将它们放入内存中。
我的部分服务器代码:
while downloadCounter<fileSize:
filedata=client.connection.recv(chunckSize)
downloadCounter=len(filedata)+downloadCounter
dataBuffer.append(bfiledata)
# save when data is 100 mb size 100000000 in binary..
if(len(dataBuffer)>=100000000):
tFILE=Thread(target=saveToDisk,)
tFILE._args=(dataBuffer,file,)
tFILE.start()
dataBuffer=NULL
【问题讨论】:
-
目前以何种方式无法按预期运行?