/Users/lyon/j4p/src/net/date/MainServer.java

1    package net.date; 
2     
3    import java.io.IOException; 
4    import java.net.ServerSocket; 
5     
6     
7    public class MainServer implements Runnable { 
8        public static final int PORT = 8086; 
9     
10       public MainServer() { 
11           Thread t = new Thread(this); 
12           t.start(); 
13       } 
14    
15       public static void main(String args[]) { 
16           new MainServer(); 
17           try { 
18               Thread.sleep(1000); 
19           } catch (InterruptedException e) { 
20           } 
21           DateClient dc = new DateClient(); 
22           System.out.println( 
23                   "Starting date client, connecting to port:" 
24                   + PORT); 
25           dc.run(); 
26           dc.run(); 
27           dc.run(); 
28       } 
29    
30       public void run() { 
31           try { 
32               ServerSocket ss = 
33                       new ServerSocket(PORT); 
34               while (true) { 
35                   System.out.println("waiting"); 
36                   new DateServer(ss.accept()); 
37               } 
38           } catch (IOException e) { 
39               e.printStackTrace(); 
40           } 
41       } 
42   }