-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
41 lines (26 loc) · 851 Bytes
/
Copy pathclient.py
File metadata and controls
41 lines (26 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import socket
import threading
import time
HOST = '192.168.1.7' # The server's hostname or IP address
PORT = 65432 # The port used by the server
def process_data_from_server(x):
return x
def my_client():
#threading.Timer(11, my_client).start()
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
while True:
my = "Data"
my_inp = my.encode('utf-8')
s.sendall(my_inp)
data = s.recv(1024).decode('utf-8')
dist = process_data_from_server(data)
print("Measured Distance = %.1f cm" % float(dist))
#s.close()
time.sleep(2)
if __name__ == "__main__":
try:
while 1:
my_client()
except KeyboardInterrupt:
print("Receiving Stopped")