make TCP server more robust
authoradam <adam@megacz.com>
Thu, 8 Feb 2007 03:49:22 +0000 (04:49 +0100)
committeradam <adam@megacz.com>
Thu, 8 Feb 2007 03:49:22 +0000 (04:49 +0100)
contrib/demo.ships
src/edu/berkeley/fleet/slipway/Server.java

index dbb3a83..c480842 100644 (file)
@@ -1,3 +1,4 @@
+#ship alu2_bad         : Alu2
 #ship alu2         : Alu2
 #ship debug        : Debug
 #ship execute      : Execute
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) { }
+            }
         }
     }