问题
I am experimenting with a file transfer program in Java and I wanted to create a server that would handle creating P2P connection between two clients.
Don't know how that should work, exchanging sockets? I don't want to exchange IP address... Seen some questions similar (ev. Connecting two clients via server java) but I have no idea how to achieve that. Thanks for your time
回答1:
It sounds like you are looking for nat traversal techniques. There is no single solution because there are many different network setups. Most p2p software employs a combination of different solutions, such as using IPv6 where available, negotiating with home routers and operating system firewalls or NAT hole punching. Servers can assist in the last point.
来源:https://stackoverflow.com/questions/48508281/java-using-server-to-create-p2p-between-two-clients