import java.io.*; import java.net.*; import java.util.*; public class Daemon extends Thread { public static ServerSocket ss = null; static Cache cache=new Cache(); //** It start and go trough parameters *// public static void main(String argv[]) { int portin=8088, portout=80; String rawUrl="http://gallop.uccs.edu"; //** Parse parameters *// System.out.println("Usage: PortIn PortOut URL"); if(argv.length==3) { portin = Integer.parseInt(argv[0]); portout = Integer.parseInt(argv[1]); //should be 80 StringTokenizer tk=new StringTokenizer(argv[2],"/"); if(tk.nextToken().equalsIgnoreCase("http:")) rawUrl = argv[2]; else rawUrl="http://"+argv[2]; } System.out.println("Inport: "+portin+" Outport: "+portout+ " Outhost: "+rawUrl); //** Open ServerSocket to listen for new request *// try { ss = new ServerSocket(portin); System.out.println("ServerSocket initiated"); while(true) { Socket clientSocket=ss.accept(); System.out.println("Connection: "+ clientSocket); Proxy thd=new Proxy(clientSocket,portout, rawUrl, cache); // Start Proxy thd.start(); } } catch (Exception e) { System.out.println("Erreur ServerSocket "+e); System.exit(10); } } }//Daemon