首先,我將所請求的文件從服務器發送到客戶端,之後我想將文件的計算後的sha從服務器發送到客戶端,以便客戶端可以檢查發送和接收的文件都是相同的。從服務器到客戶端的多個發送python
我設法發送的文件,但是當我嘗試也派沙(這是一個可變的)我收到一個錯誤(我相信莎也被添加到該文件的內容)
我怎麼能將它們分開發送?
if (reqCommand == 'get'):
with open (reqFile, 'rb') as in_file, open(encFile, "wb") as out_file:
encrypt(in_file, out_file, "abc")
f = open(encFile,'rb')
for data in f:
# print 'here3'
conn.sendall(data)
f.close()
file_sh = hashfile(reqFile)
print 'the sha1 function from the server: ', file_sh
conn.send(file_sh)
和客戶端:
while True:
data = sock.recv(1024)
if not data:
break
#print data
file_to_write.write(data)
請問你能給我一個簡短的例子嗎?我仍然面臨問題 – spoke
你到底在哪裏遇到問題?我不知道如何在評論中編寫代碼。 – CristiFati
必須跑步,我可能會看看晚些時候或明天。 – CristiFati