1 26 27 package org.objectweb.benchmark.util; 28 29 import java.io.IOException ; 31 import java.net.ServerSocket ; 32 import java.net.Socket ; 33 34 41 public class PortAgent 42 { 43 public static void 44 main(String [] args) 45 { 46 int port = 0; 47 48 if (args.length < 2) 49 { 50 System.err.println("usage: PortAgent activate|wait_for_activation <port> [host]"); 51 System.exit(0); 52 } 53 port = Integer.parseInt(args[1]); 54 55 if (args[0].compareTo("activate") == 0) 56 { 57 try 59 { 60 Socket socket = new Socket (args[2], port); 61 socket.sendUrgentData(0); 62 } catch (IOException e) { 63 e.printStackTrace(); 64 } 65 } 66 else if (args[0].compareTo("wait_for_activation") == 0) 67 { 68 try 70 { 71 ServerSocket s = new ServerSocket (port); 72 Socket socket = s.accept(); s.close(); 74 } catch (IOException e) { 75 e.printStackTrace(); 76 } 77 } 78 } 79 80 } 81 | Popular Tags |