views:

57

answers:

2

Hello,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?

A: 

It really depends what you mean by 'server'. You dont need a centralized server by any means. The term 'p2p', by its very definition, implies no centralized server.

But the apps that receive data from other apps need to be able to listen for incoming tcp/ip connections... thats typically considered 'server' functionality, even if you arent calling it a 'server'. So in your case, your p2p app would need to have both server and client (initiating connections) capabilities built into it.

GrandmasterB
That's corrent, my point that users will not be in need to have external ip. Is IT possible?
Their machines wont need externally addressable IPs. ie, they can be on a local network. BUT their routers/modems - the pieces that actually connect to the internet - will have externally adressable IP addresses. They'll just have to be set up to forward ports. That can be done manually or via UPnP.
GrandmasterB
A: 

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.)

Frank Shearar