I'll like to computers/clients to connect directly to each other in the case where one or both of them haven't got a public IP. I guess this could be done with a server as a middle man. The connection established in the end must be direct traffic between the clients. How is this possible, and what is the technic called?
I'll really like to see some code fx in Java.
Thanks
If port forwarding is not an option, there is a mostly-reliable technique you can use with UDP traffic called NAT traversal. It requires a middle-man server to act as a rendezvous point, but after the initial set-up all traffic will be endpoint-to-endpoint.
This will not work in all cases; it depends on how the various NAT layers map external endpoints to internal entpoints.
TCP NAT traversal is very difficult to implement and has an extremely low chance of even working.
(I have successfully used UDP NAT traversal to establish an OpenVPN connection between two computers at different universities, both behind several NAT layers!)