Esempio n. 1
0
 public void run() {
   boolean status;
   sf.DEBUG("Listen server running.");
   // open up our server socket
   try {
     m_serverSocket = new ServerSocket(m_nPort);
   } catch (IOException e) {
     sf.VERBOSE("Could not listen on port: " + m_nPort);
     if (sf.cntrlWndw != null) {
       sf.cntrlWndw.ClearListenServer();
     }
     return;
   }
   sf.VERBOSE("Listening for client connections on port " + m_nPort);
   // if (SerialForward.bSourceSim)
   // {
   SetDataSource();
   sf.InitSerialPortIO();
   // }
   // start listening for connections
   try {
     ClientServicer rcv;
     Socket currentSocket;
     while (!m_bShutdown) {
       currentSocket = m_serverSocket.accept();
       ClientServicer newServicer = new ClientServicer(currentSocket, sf, this);
       newServicer.start();
       vctServicers.add(newServicer);
     }
     m_serverSocket.close();
   } catch (IOException e) {
     /*try { this.sleep(500); }
     catch (Exception e2) { }*/
     sf.VERBOSE("Server Socket closed");
   } finally {
     ShutdownAllClientServicers();
     if (sf.serialPortIO != null) sf.serialPortIO.Shutdown();
     sf.VERBOSE("--------------------------");
     if (sf.cntrlWndw != null) {
       sf.cntrlWndw.ClearListenServer();
     }
   }
 }
Esempio n. 2
0
 public void ShutdownAllClientServicers() {
   sf.VERBOSE("CLIENTSERVICER: Shutting down all client connections");
   ClientServicer crrntServicer;
   while (vctServicers.size() != 0) {
     crrntServicer = (ClientServicer) vctServicers.firstElement();
     crrntServicer.Shutdown();
     try {
       crrntServicer.join(1000);
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
     ;
   }
 }