views:

85

answers:

1

I am writing a peer-to-peer binary socket program. There are only two endpoints. One socket is listening on my laptop system. The other socket is broadcasting from my desktop system. I have a third program running on a hosted server, that is available to broker the connection between the two. My problem is that when the laptop and desktop are on the same network, they both have the same internet IP address but different intranet IPs, but when the laptop is on the road, then the IP addresses are different. In order to be truly peer-to-peer, I have to write it so that after the connection is established, that the two computers communicate directly between one another. How is this generally accomplished, when the two computers could potentially share the same IP address, if they are running on the same network?

A: 

Your question is really: how do I deal with network address translation in a P2P system?

One possibility is to require holes poked in the NAT/firewall systems--that will ensure that requests to a given port are sent to a given computer. Allowing multiple clients inside the network would require poking multiple holes and configuring each client with the corresponding port.

Another possibility involving UDP is here--I haven't reviewed it enough to know if it really removes the broker from the equation after a handshake.

As always, Google can be your friend.

Michael Brewer-Davis
Thank you, I was not aware of the proper terminology.
Joshua