views:

73

answers:

2

I would like to have a Java program running on network A have a ServerSocket living on another network B through a proxy. I have played with a SOCKS5 proxy (which works) but it appears that all the proxy facilities in Java only work with client connections, not with ServerSockets (no constructor taking a Proxy argument). Asking Google gives much hay and few needles.

What is the approach I should take to get this running?

If a specific client is better than a generic SOCKS or web proxy then fine, but it needs to be Java (that leaves sshd out).

Target JVM is preferrably Java 5, and then Java 6.

A: 

Proxying is a client issue and server shouldn't care. For example, the server on network B is no different from any other servers. The client and proxy are responsible to make connection to it from other networks.

On server side, the only thing you might care is to find out the original IP address of the client. To server, the connection is from proxy.

ZZ Coder
Unless the proxy on network B makes the ServerSocket, applications cannot reach the server code on network A, which is what I need.
Thorbjørn Ravn Andersen
You have 2 options to go across networks. You either make the server multi-homed (with 2 IP addresses, one on each network) and ServerSocket will listen on both if you don't specify an IP. Or you connect through a SOCKS proxy which forward packets from A to B. Either way, you don't need a server proxy setting and you will not find one.
ZZ Coder
+1  A: 

Why not just set up an stunnel to deal with forwarding the traffic from one network to the other? As ZZ Coder mentions this isn't a server issue and so the solution should live outside your Java application codebase IMHO.

Adamski
As I mentioned in the question, sshd is not an option.
Thorbjørn Ravn Andersen