Esempio n. 1
0
 /**
  * Establishes the threads to handle the clients
  *
  * @param pn Sever panel to send output to
  */
 public Server(ServerPanel pn) {
   panel = pn;
   clientList = new ClientList();
   try {
     serverSocket = new ServerSocket(0);
   } catch (Exception e) {
     JOptionPane.showMessageDialog(panel, "Unrecoverablable establishing a server socket");
     e.printStackTrace();
     System.exit(1);
   }
   try {
     String hostName = InetAddress.getLocalHost().getHostAddress();
     int port = serverSocket.getLocalPort();
     panel.setInfo(hostName, port);
   } catch (UnknownHostException e) {
     JOptionPane.showMessageDialog(panel, "Unable to connet client to self");
     e.printStackTrace();
     System.exit(1);
   }
   this.start();
 }