I'm not yet sure if this is possible, and I'm looking for where more information might be found. It's mostly being done as an exercise, but I want to see if I can implement this at all as a solution to sharing very large files with minimal hassle between two individuals (and I realize some solutions might exist that are similar, but I still want to try and write one).
Basic setup is as follows: I'm figuring on configuring a server with a program that listens on port XYZ. I'd have two example users (A and B). User "A" wants to share a file with user "B". "A" goes to his local client and pushes some information to the server. He gets back a key that he can send to user "B" however he likes (instead of publishing or broadcasting the location). User "B" gets the key, puts it into his client. His client goes to the server and gets the information on how to connect to User "A"s machine for the file transfer.
Now, this is simple enough with machines that can connect via a socket directly, but I'm assuming user A and B are on completely different networks, behind different public IP's (normal internet users). So what I wondered is, can I have user "A" and user "B" monitor a status on the server, and when it's apparent that it's time to share the file, use the server as a bridge to connect the two somehow ... communicate a handshake and then either a new socket, or somehow join sockets connected to the server? The caveat in this whole thing is that I'd like the bandwidth not to be transferred along the server (or I could just initiate direct connections to the server), but directly peer to peer between the two machines, using the server only to negotiate a connection.
But I've no idea where to look on information about this, or if it's possible :)
My preference is to use Java.
In order to directly connect the two sockets without using the server as a broker, one will have to have the ability to be hit directly as an endpoint.
I can think of no facility that can negotiate two connections behind a NAT or PAT and then drop out of the loop leaving the other two connected.
If you can build into the design spec that the clients must have their respective listen ports open and mapped in whatever system they use to route then it would be possible.