-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
33 lines (30 loc) · 958 Bytes
/
Copy pathserver.py
File metadata and controls
33 lines (30 loc) · 958 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
import socket
import sys
import json
import numpy as np
port = 8220
address = ('', port)
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(address)
server_socket.listen(5)
print "Listening for client . . ."
conn, address = server_socket.accept()
print "Connected to client at ", address
#pick a large output buffer size because i dont necessarily know how big the incoming packet is
i=0
while i<10:
output = conn.recv(2048);
if output.strip() == "disconnect":
conn.close()
sys.exit("Received disconnect message. Shutting down.")
conn.send("dack")
break
elif output:
print "Message received from client:"
#print json.loads(output)
json_load = json.loads(output)
restored = np.asarray(json_load["data"])
#print(restored)
np.save("otherCameraCenter",restored)
conn.send("ack")
i=i+1