int thePort;
ServerSocket ss;
try {
theSite = args[0];
}
catch (Exception e) {
theSite = "http://www.ora.com";
}
// trim trailing slash
if (theSite.endsWith("/")) {
theSite = theSite.substring(0, theSite.length()-1);
}
try {
thePort = Integer.parseInt(args[1]);
}
catch (Exception e) {
thePort = 80;
}
try {
ss = new ServerSocket(thePort);
System.out.println("Redirecting connections on port " + ss.getLocalPort()
+ " to " + theSite);
while (true) {
Redirector rd = new Redirector(ss.accept());
rd.start();
}
}
catch (IOException e) {
}