aboutsummaryrefslogtreecommitdiff
path: root/python/server.py
blob: c36f073d28399c402ee19d8abb7dbd343f545afe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/python

import gats
import socket
import time

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(('', 5051))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
while 1:
	print 'Reading...'
	obj = gats.recv( conn )
	print 'Read',obj
	gats.send( {'recvAddr': addr, 'recvTime': time.time(), 'recvObj': obj }, conn )
conn.close()