-
Peer to Peer
Hey dudes, I am having a major problem with some sort of programming and did not know where else to turn. I am trying to make a peer to peer networking program. I have a basic layout idea, one server on my home computer that will store all of the clients connected, then all the clients will send information between them. This part is easy, but the bit I am struggeling with is if the clients (one or both) are behind routers and I cant make one of them listen for connections from the other one. Help anyone??? I do hope that this, well most of this, makes sence.
P.S. If there is some sort code similar to this that has been listed before, kindly point it out as there are quite a few results when you search for peer to peer, and I may have missed it. Thanks in advance
-
Re: Peer to Peer
There is no elegant solution to this problem.
Many techniques exist, and all of them require at least some help from a server that is publicly available. As far as I know they all work only to a limited extent on some routers (if at all).
Even if there are no NAT devices involved "discovery" is a problem unless everyone has a DNS name or fixed IP address that everyone else knows.
If the traffic load is light you may as well just create a server-centric application. If heavier (lots of images or files passed around) it becomes more problematic. Then you are back to reading up on all of those articles you found while searching the web.
I believe most viable P2P systems try to use one or more of the NAT hacks, and even then fall back to server-based communication if they fail.
Sadly there's no silver bullet. It's just as well though, malware manages to spread itself and excrete spam and harvest personal info fast enough as it is.
-
Re: Peer to Peer
DAMN! But, I have got a main server that will keep track of all the clients, but as you said, there are large amounts of data are being transfered. What I am looking for is a system similar to the Torrent P2P System. Where there is a tracker that keeps track of all the people, and then all the people send chuncks of data between themselves. Any ideas on that anyone?
-
Re: Peer to Peer
Probably not an elegant solution but...
have you considered using the DirectPlay part of DirectX, I believe that allows for discovery of sessions on remote computers and you can choose between *****Peer or a Client-Server approach
-
Re: Peer to Peer
now thats a shame. Is there any open source code out there with would allow me to make my own system from scratch?
-
Re: Peer to Peer
Torrent keeps a directory of computers that are available, but they still have to have ports forwarded to be connected to, which will work for your program too. You can't request a connection to a computer behind a NAT device without some help. Think about it - once your request gets to the router, which computer is it going to go to? Unless that port is forwarded to a particular computer, the router doesn't have a clue. Outgoing requests (requests generated by the computer behind the router) give the router a clue that there's going to be a response.
Either use one server that's not behind a router (like most of the chat programs) or open a port on all routers involved. (Most programs, even big commercial ones, that listen for connections require an open port.)
-
Re: Peer to Peer
No, there are tricks to get a port opened up through a NAT router. They only work on some routers though.
It involves two clients behind NAT connecting to a central visible server, then the server can get the two clients directly connected through the "holes" that have been temporarily punched through the two routers.
Basically impractical though, maybe impossible using just VB.
Google for "NAT traversal" and read a few of the resulting hits. "Teredo" is also interesting to read up on.
-
Re: Peer to Peer
Nifty, is there any source code available?
-
Re: Peer to Peer
Upon further investigation into this fangled NAT Traversal idea, I found a method called UDP Hole Punching. Anyone have any code references to that? It appears to be exactly the system I am looking for.