im2.save(buf, "JPEG", quality=quality)
elapsed_time += time.time() - t
-print("compute scale jpg ",elapsed_time/nb_times, " / size of file ",Path('lena3.jpg').stat().st_size)
+print("compute scale 4 jpg ",elapsed_time/nb_times, " / size of file ",Path('lena3.jpg').stat().st_size)
sbuf.put_bytes(f.read())
# print('File Sent')
elapsed_time += time.time() - t
- print("send scale jpg ",elapsed_time/nb_times)
+ print("send scale 4 jpg ",elapsed_time/nb_times)
--- /dev/null
+# ----- receiver.py -----
+
+#!/usr/bin/env python
+
+from socket import *
+import sys
+import select
+import time
+
+host="0.0.0.0"
+port = 9999
+s = socket(AF_INET,SOCK_DGRAM)
+s.bind((host,port))
+
+addr = (host,port)
+buf=1024
+
+
+data,addr = s.recvfrom(buf)
+elapsed_time=0
+t = time.time()
+print("Received File:",data.decode().strip())
+f = open(data.decode().strip()+"2",'wb')
+
+data,addr = s.recvfrom(buf)
+try:
+ while(data):
+ f.write(data)
+ s.settimeout(2)
+ data,addr = s.recvfrom(buf)
+except timeout:
+ s.close()
+ f.close()
+# print("File Downloaded")
+elapsed_time += time.time() - t
+
+print("receive bmp",elapsed_time)
--- /dev/null
+# ----- sender.py ------
+
+#!/usr/bin/env python
+
+from socket import *
+import sys
+import time
+
+s = socket(AF_INET,SOCK_DGRAM)
+host =sys.argv[1]
+port = 9999
+buf =1024
+addr = (host,port)
+
+file_name=sys.argv[2]
+elapsed_time=0
+t = time.time()
+s.sendto(file_name.encode(),addr)
+
+f=open(file_name,"rb")
+data = f.read(buf)
+while (data):
+ if(s.sendto(data,addr)):
+# print "sending ..."
+ data = f.read(buf)
+
+f.close()
+elapsed_time += time.time() - t
+
+print("receive bmp",elapsed_time)
+s.close()