From c9ff9e8bb98709eabcfb7f1bc922d3f9649d7f31 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Couturier?= Date: Mon, 12 Jul 2021 11:49:02 +0200 Subject: [PATCH 1/1] new --- measure_energy_iot/client_tcp4.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/measure_energy_iot/client_tcp4.py b/measure_energy_iot/client_tcp4.py index b96dbd3..f8b73f0 100644 --- a/measure_energy_iot/client_tcp4.py +++ b/measure_energy_iot/client_tcp4.py @@ -1,7 +1,7 @@ import socket import threading import os - +import time import buffer HOST = 'bilbo' @@ -14,11 +14,10 @@ with s: sbuf = buffer.Buffer(s) -# files = input('Enter file(s) to send: ') - # files_to_send = files.split() + elapsed_time=0 + t=time.time() file_name="lena.jpg" for i in range(10): -# for file_name in files_to_send: print(file_name) sbuf.put_utf8(file_name) @@ -28,5 +27,23 @@ with s: with open(file_name, 'rb') as f: sbuf.put_bytes(f.read()) print('File Sent') + elapsed_time += time.time() - t + print("send lena ",elapsed_time) + + elapsed_time=0 + t=time.time() + file_name="lena2.jpg" + for i in range(10): + print(file_name) + sbuf.put_utf8(file_name) + + file_size = os.path.getsize(file_name) + sbuf.put_utf8(str(file_size)) + + with open(file_name, 'rb') as f: + sbuf.put_bytes(f.read()) + print('File Sent') + elapsed_time += time.time() - t + print("send lena ",elapsed_time) -- 2.39.5