-
P2p vb6
Has anyone done any P2P projects that work over the Internet? I'm not talking about file sharing, more things like chat without a central chat server.
I have a prototype chat application that seems promising. It involves each peer communicating by sending UDP datagrams to all of the other peers.
To handle "discovery" it relies on a public WebDAV server. Each user starts the program and supplies a user name and "password." Then the program opens the local firewall, selects a UDP port, maps the port through the local NAT router (if any), and checks for then posts (or re-posts) a "name" file to the WebDAV server.
This "name" file contains the user's external IP address, port number, and password. The password is only meant to be checked when a user picks a new name - so the chat program can check to make sure the user didn't pick a name somebody else is using. It isn't meant as a security measure.
At this point the program retrieves the list of "name" files and uses the contents to send a "ping" datagram to each user found. As users "pong" back they're added to the list of people in the chat. These "pongs" also contain each user's current IP and port.
By using several ports in this way instead of a fixed port number you can have multiple users chatting from behind the same NAT server. I'm saving the user/password in an "ini" file so users don't have to enter it each time. This is all that keeps you from running multiple copies on the same PC, and could be modified.
Using a WebDAV server means you need no server-side logic. I understand people do similar things using PHP/ASP/etc. code on a public server but this approach is slightly simpler.
The program needs to have the URL of the WebDAV chat names folder of course, as well as credentials allowing access (at least create and replace access). Right now I'm just mildly encrypting these in the EXE, but I can see a need to remove them to an external file that can be updated when required.
Right now I'm not worried, since this is just a proof of concept.
So far the prototype seems to be working fine. The only glitches seem to be: (1.) forgetting to allow UPnP through the firewall (I did this myself and was scratching my head for quite a while), and (2.) sometimes trying to grab a free UDP port fails.
The former is merely procedural. The latter might be something else, though it acts like the system doesn't have any free UDP ports available at the time. Restarting the program almost always works.
There is also the matter of using plain old UDP. Datagrams can be lost and I haven't tried to implement any kind of detection/retry.
Aside from the discovery server (WebDAV) no central server is needed. Several free WebDAV hosts can be used.
-
re: P2P VB6
Hmm, sorry about the typos (wrong case) in the title. I guess I can't edit that.