diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-01-16 16:42:17 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-01-16 16:42:17 +0000 |
commit | 4843dede4add1764ced095ecf3e41ecc3a53240e (patch) | |
tree | cea32f881e5760dd417e3e8a0eaf2b3b15ecd32e /python/server.py | |
parent | dfeb2636eb83098ebd621ce2add83ef9e256318f (diff) | |
download | libgats-4843dede4add1764ced095ecf3e41ecc3a53240e.tar.gz libgats-4843dede4add1764ced095ecf3e41ecc3a53240e.tar.bz2 libgats-4843dede4add1764ced095ecf3e41ecc3a53240e.tar.xz libgats-4843dede4add1764ced095ecf3e41ecc3a53240e.zip |
Added networking compatible send/recv functions as helpers, plus a bunch of
docs.
Diffstat (limited to 'python/server.py')
-rwxr-xr-x | python/server.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/python/server.py b/python/server.py new file mode 100755 index 0000000..c36f073 --- /dev/null +++ b/python/server.py | |||
@@ -0,0 +1,18 @@ | |||
1 | #!/usr/bin/python | ||
2 | |||
3 | import gats | ||
4 | import socket | ||
5 | import time | ||
6 | |||
7 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
8 | s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | ||
9 | s.bind(('', 5051)) | ||
10 | s.listen(1) | ||
11 | conn, addr = s.accept() | ||
12 | print 'Connected by', addr | ||
13 | while 1: | ||
14 | print 'Reading...' | ||
15 | obj = gats.recv( conn ) | ||
16 | print 'Read',obj | ||
17 | gats.send( {'recvAddr': addr, 'recvTime': time.time(), 'recvObj': obj }, conn ) | ||
18 | conn.close() | ||