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 peer-to-peer network is one in which two or more PCs share files and access to devices such as printers without requiring a separate server computer or server software.
P2P (peer-to-peer) networks are used for distributing files on a network. On a P2P network, each computer acts as both a server and a client, storing and sharing files with other computers on the network.
Six out of nine analyzed P2P protocols use both TCP and UDP as layer-4 transport protocols. These protocols include eDon- key, Fasttrack, WinMx, Gnutella, MP2P and Direct Con- nect. Generally, control traffic, queries and query-replies use UDP, and actual data transfers use TCP.
So in brief: port forwarding helps with the health of P2P data exchange by making it easier for connections to be established - and unless every member enables port forwarding of some kind, it is impossible to exchange data in a P2P manner.
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.)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With