Esempio n. 1
0
 /** Start the server that listens on a socket for command line arguments. */
 public static void startServer() {
   try {
     CommandLineArgsServer server = new CommandLineArgsServer();
     server.start();
   } catch (IOException e) {
     IdeLog.logError(CommandlineLauncherPlugin.getDefault(), e);
   }
 }
Esempio n. 2
0
    /** @see java.lang.Runnable#run() */
    public void run() {
      if (server == null) {
        return;
      }

      while (server.isClosed() == false) {
        Socket clientSocket = null;
        try {
          clientSocket = server.accept();

          BufferedReader r =
              new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
          BufferedWriter w =
              new BufferedWriter(new OutputStreamWriter(clientSocket.getOutputStream()));

          List<String> args = new LinkedList<String>();
          while ((line = r.readLine()) != null) {
            args.add(line);
          }
          if (args.size() > 0) {
            // Process command line arguments
            CommandlineArgumentsHandler.processCommandLineArgs(args.toArray(new String[0]));
          }

          // Send ACK
          w.write("pong"); // $NON-NLS-1$
          w.flush();
        } catch (IOException e) {
          IdeLog.logError(CommandlineLauncherPlugin.getDefault(), e);
        } finally {
          if (clientSocket != null) {
            try {
              clientSocket.close();
            } catch (IOException e) {
              // Ignore
            }
          }
        }
      }
    }