make TCP server more robust
[fleet.git] / src / edu / berkeley / fleet / slipway / Server.java
index cabbeda..67c5a57 100644 (file)
@@ -21,8 +21,8 @@ public class Server {
         private int devnum;
         public Listener(int devnum) { this.devnum = devnum; }
         public void run() {
-            try {
-                while(true) {
+            while(true) {
+                try {
                     Socket s = null;
                     synchronized(Server.class) {
                         System.err.println("thread " + devnum + " listening");
@@ -30,8 +30,9 @@ public class Server {
                         System.err.println("connection");
                     }
                     new Handler(s, devnum).run();
-                }
-            } catch (Exception e) { throw new RuntimeException(e); }
+                } catch (Exception e) { throw new RuntimeException(e); }
+                try { Thread.sleep(1000); } catch (Exception e) { }
+            }
         }
     }