Mercurial > code > home > repos > light9
annotate light8/potserver.py @ 91:7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
author | drewp |
---|---|
date | Sat, 13 Jul 2002 02:57:55 +0000 |
parents | 238fbd5266ea |
children | d8e2492e2947 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 | |
91
7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents:
88
diff
changeset
|
3 import socket,time |
0 | 4 |
5 from io import * | |
6 | |
7 pots = SerialPots() | |
8 pots.golive() | |
9 | |
91
7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents:
88
diff
changeset
|
10 laste="" |
0 | 11 while 1: |
91
7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents:
88
diff
changeset
|
12 |
0 | 13 l=pots.getlevels() |
91
7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents:
88
diff
changeset
|
14 |
0 | 15 try: |
16 s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
91
7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents:
88
diff
changeset
|
17 s.setblocking(1) |
7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents:
88
diff
changeset
|
18 ret=s.connect_ex(("dash", socket.getservbyname('rlslider','tcp'))) |
7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents:
88
diff
changeset
|
19 # print ret |
0 | 20 s.send("%d %d %d %d\n" % l) |
21 s.close() | |
22 except Exception,e: | |
91
7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents:
88
diff
changeset
|
23 print str(e) |
7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents:
88
diff
changeset
|
24 s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents:
88
diff
changeset
|
25 if ret==111: |
7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents:
88
diff
changeset
|
26 print time.ctime(),"waiting for server" |
7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents:
88
diff
changeset
|
27 time.sleep(3) |
7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents:
88
diff
changeset
|
28 else: |
7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents:
88
diff
changeset
|
29 print time.ctime(),"connected" |
0 | 30 |
31 | |
91
7f273883de60
messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents:
88
diff
changeset
|
32 |