comparison 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
comparison
equal deleted inserted replaced
90:d34a4956417a 91:7f273883de60
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 import socket 3 import socket,time
4 4
5 from io import * 5 from io import *
6 6
7 pots = SerialPots() 7 pots = SerialPots()
8 pots.golive() 8 pots.golive()
9 9
10 laste=""
10 while 1: 11 while 1:
12
11 l=pots.getlevels() 13 l=pots.getlevels()
14
12 try: 15 try:
13 s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) 16 s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
14 s.connect(("dash", socket.getservbyname('serpots','tcp'))) 17 s.setblocking(1)
15 18 ret=s.connect_ex(("dash", socket.getservbyname('rlslider','tcp')))
19 # print ret
16 s.send("%d %d %d %d\n" % l) 20 s.send("%d %d %d %d\n" % l)
17 s.close() 21 s.close()
18 except Exception,e: 22 except Exception,e:
19 print "Exception: %s" % e 23 print str(e)
24 s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
25 if ret==111:
26 print time.ctime(),"waiting for server"
27 time.sleep(3)
28 else:
29 print time.ctime(),"connected"
20 30
21 31
32