1

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

Milut
  • 13
  • 5
  • 1
    What's wrong with sending the IP to one client, and tell the other client to listen for a connection? What the linked question suggests, is to use the server as a bridge between the two clients (with all data being sent through the server, not directly to the other client) – phflack Jan 29 '18 at 19:09
  • Because sending IPs would require forwarding ports, wouldn't it? (correct me if im wrong) Also I don't want to do the whole transmission through server because it make the servers bandwidth a limiting factor – Milut Jan 29 '18 at 20:32
  • 1
    As far as I know, you need to either deal with the firewalls or be stuck with the server in the middle. I haven't come across a method that would redirect the open ports to eachother _(which I really want, for my projects)_ – phflack Jan 29 '18 at 20:36

1 Answers1

0

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.

the8472
  • 40,999
  • 5
  • 70
  • 122
  • Thanks, I've started looking into that. Probably will try to settle on hole punching, what pains me is from what I've read it won't be always effective... Well, will post here if I develop some working piece of code. Thank you – Milut Jan 30 '18 at 18:49