aboutsummaryrefslogtreecommitdiff
path: root/python/server.py
blob: 3dc60cb29cd604e3033f8f046cee78cd1ee05600 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/python
#
# Copyright (C) 2007-2012 Xagasoft, All rights reserved.
#
# This file is part of the libgats library and is released under the
# terms of the license contained in the file LICENSE.
#

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()