#!/usr/bin/python # # Copyright (C) 2007-2013 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()