]> AND Private Git Repository - Cipher_code.git/blob - measure_energy_iot/sender.py
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Merge branch 'master' of ssh://info.iut-bm.univ-fcomte.fr/Cipher_code
[Cipher_code.git] / measure_energy_iot / sender.py
1 # ----- sender.py ------
2
3 #!/usr/bin/env python
4
5 from socket import *
6 import sys
7 import time
8
9 s = socket(AF_INET,SOCK_DGRAM)
10 host =sys.argv[1]
11 port = 9999
12 buf =1024
13 addr = (host,port)
14
15 file_name=sys.argv[2]
16 elapsed_time=0
17 t = time.time()
18 s.sendto(file_name.encode(),addr)
19
20 f=open(file_name,"rb")
21 data = f.read(buf)
22 while (data):
23     if(s.sendto(data,addr)):
24 #        print "sending ..."
25         data = f.read(buf)
26
27 f.close()
28 elapsed_time += time.time() - t
29
30 print("receive bmp",elapsed_time)
31 s.close()