changeset 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 d34a4956417a
children 827a675131dc
files light8/potserver.py
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/light8/potserver.py	Sat Jul 13 02:57:27 2002 +0000
+++ b/light8/potserver.py	Sat Jul 13 02:57:55 2002 +0000
@@ -1,21 +1,32 @@
 #!/usr/bin/python
 
-import socket
+import socket,time
 
 from io import *
 
 pots = SerialPots()
 pots.golive()
 
+laste=""
 while 1:
+    
     l=pots.getlevels()
+        
     try:
         s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-        s.connect(("dash", socket.getservbyname('serpots','tcp')))
-
+        s.setblocking(1)
+        ret=s.connect_ex(("dash", socket.getservbyname('rlslider','tcp')))
+#        print ret        
         s.send("%d %d %d %d\n" % l)
         s.close()
     except Exception,e:
-        print "Exception: %s" % e
+        print str(e)
+        s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        if ret==111:
+            print time.ctime(),"waiting for server"
+            time.sleep(3)
+        else:
+            print time.ctime(),"connected"
 
 
+