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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
1 #!/usr/bin/python
45b12307c695 Initial revision
drewp
parents:
diff changeset
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
45b12307c695 Initial revision
drewp
parents:
diff changeset
4
45b12307c695 Initial revision
drewp
parents:
diff changeset
5 from io import *
45b12307c695 Initial revision
drewp
parents:
diff changeset
6
45b12307c695 Initial revision
drewp
parents:
diff changeset
7 pots = SerialPots()
45b12307c695 Initial revision
drewp
parents:
diff changeset
8 pots.golive()
45b12307c695 Initial revision
drewp
parents:
diff changeset
9
91
7f273883de60 messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents: 88
diff changeset
10 laste=""
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
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
45b12307c695 Initial revision
drewp
parents:
diff changeset
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
45b12307c695 Initial revision
drewp
parents:
diff changeset
15 try:
45b12307c695 Initial revision
drewp
parents:
diff changeset
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
45b12307c695 Initial revision
drewp
parents:
diff changeset
20 s.send("%d %d %d %d\n" % l)
45b12307c695 Initial revision
drewp
parents:
diff changeset
21 s.close()
45b12307c695 Initial revision
drewp
parents:
diff changeset
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
45b12307c695 Initial revision
drewp
parents:
diff changeset
30
45b12307c695 Initial revision
drewp
parents:
diff changeset
31
91
7f273883de60 messed with the server a lot. it works, though doesnt do persistent conenctions
drewp
parents: 88
diff changeset
32