Thanks Nathan.
HTTP tunneling will not work here because the events that the server-side are posting back to client GUI are each running in their own
thread.
That's why I need the pool of sockets which I will have the firewall opened for.
Here is what I have come up with so far if you would like to look at it and give me your initial feed-back:
public class FixedPortRMISocketFactory extends RMISocketFactory {
public static Integer pv;
public static int clPort = 6051;
public static int svPort = 6000;
/**
* Creates a client socket connected to the specified host and port and writes out debugging info
* @param host the host name
* @param port the port number
* @return a socket connected to the specified host and port.
* @exception IOException if an I/O error occurs during socket creation
*/
public Socket createSocket(
String host, int port)
throws IOException {
InetAddress ip = InetAddress.getLocalHost();
synchronized (this) {
//return new Socket(host, port);
System.out.println (" Thread : " + Thread.currentThread());
try {
Socket clSock = new Socket(host, port, ip, clPort);
System.out.println("created client socket to host : " + host + " on serverport " + port + " localip " + ip.getHostAddress() + " localPort " + clPort);
return clSock;
}
catch (Exception e){
System.out.println("Cannot create Client socket at port " + clPort + " : " + e.toString());
throw new IOException();
}
}
}
/**
* Create a server socket on the specified port (port 0 indicates
* an anonymous port) and writes out some debugging info
* @param port the port number
* @return the server socket pool for array access of sockets by the event thread caller
* @exception IOException if an I/O error occurs during server socket
* creation
*/
public ServerSocket createServerSocket(int port)
throws IOException {
port = (port == 0 ? svPort : port);
ServerSocket svSockPool[] = new ServerSocket[50];
for ( sockID = port; sockID < 6051 ; sockID++ )
{
ServerSocket svSock;
try {
svSockPool[sockID] = new ServerSocket(sockID);
svSock = svSockPool[sockID];
System.out.println("created ServerSocket on serverport " + sockID);
svPort ++ ;
if(svPort == 6050)
svPort = 6000;
/* svPort pool at end of range so reset to 6000 */
}
catch (Exception e){
System.out.println("Cannot create Server socket at port " + port + ": " + e.toString());
throw new IOException();
}
return (ServerSocket)svSockPool[];
}
}
}