TCP P2P without server

user380798 picture user380798 · Aug 2, 2010 · Viewed 13.5k times · Source

is it possible to write TCP P2P program without server? When I was googling this question I found something about NAT traversal,UPnP, can I use them somehow?

Answer

Frank Shearar picture Frank Shearar · Aug 3, 2010

Yes you can (where as GrandmasterB points out, each peer has both server and client sockets). However, NATs will cause you pain, as you may already know.

If you can't use middleboxes (servers on public IP addresses to which your clients connect (*)) - and you might not want these, because they're rather contrary to the point of P2P - and you don't mind describing your connection details with SDP, you could try Interactive Connectivity Establishment.

Essentially, ICE tries different strategies to connect. It's a pluggable architecture, so you could add your own custom strategies. By default ICE describes techniques for UDP traversal, but an extension to allow TCP connectivity is in the works.

(*) You could always try an architecture like IRC, where you have any number of servers peering amongst themselves, to which clients connect. That's halfway to P2P at least. (This is also pretty much the architecture SIP uses.)