package PortForwarder;
import java.net.*;
public class JustListen {
int listenPort = 0;
String destName = null;
int destPort= 0;
ServerSocket serverSocket = null;
public JustListen(int listenPort) {
this.listenPort = listenPort;
try {
serverSocket = new ServerSocket(listenPort);
}
catch(Exception e) {
System.err.println("Exception creating serverSocket:"+e);
e.printStackTrace();
}
}
public void go() {
while(true) {
try {
Socket inConnection = serverSocket.accept() ;
System.err.println("New connection established with "+ inConnection);
JustListenHandler inHandler = new JustListenHandler(inConnection);
}
catch(Exception e) {
System.err.println("Exception in go:"+e);
e.printStackTrace();
}
}
}
public static void main(String argv[]) {
int listenPort = 0;
if(argv.length != 1) {
System.err.println("usage: JustListen listenPort");
System.exit(1);
}
listenPort = Integer.parseInt(argv[0]);
JustListen jl = new JustListen(listenPort);
jl.go();
}
}