Saoud Rizwan
Saoud Rizwan

Reputation: 1

How can I code a web app p2p network?

I wanted to code a web application, where one user can choose a file and other multiple users can download that specified file off of that user's computer. That user would have to leave his computer on and leave the web page open.

I dont want to have a big main server that has to handle all that traffic. That user's computer is the server, persay. I understand I'll use torrent.

All this has to be done on a website.

Will a web socket work?

Please and Thanks.

Upvotes: 0

Views: 645

Answers (3)

user752583
user752583

Reputation: 1

You could use a c# client library to interface to bittorrent or etc and use this mode to upload/leach. As far as NAT/Firewall issues go they are well documented and a function of the protocol being used, ie deal with it.

Upvotes: 0

debracey
debracey

Reputation: 6607

This really isn't possible for a variety of reasons:

  • Firewalls / NATs
  • Dynamic IPs
  • No "server" running on the user's machines
  • Permissions on the user's machine
  • What happens if the user simply deletes the file on their machine?

To actually make it work you'd have to:

  • Convince the user to install the app on their machine (you'd need a windows/linux/... EXE)
  • Get the user to open a port in the firewall (or use some library to enable NAT passthru)
  • Have the user's PC ping your server in the event the user's IP changes

On the server side, you'd have to keep several database tables, here are few I can think of off the top of my head:

  • A user's table (user ID [PK], Current IP, Communications Port, (maybe some other tracking things))
  • Available downloads table (download ID [PK], user ID [FK])

Then when someone wants to go off and download, you have to (probably) launch your app with the requisite arguments (remote user's IP/port/file ID) and have that do the work of the download.

This is by no means an easy feat.

Upvotes: 2

cahz
cahz

Reputation: 48

If by WebSockets you mean the HTML5 variety, I'd stay away from that. http://en.wikipedia.org/wiki/WebSockets#Browser_support

The the computer that has to stay on, is basically your server. Even if it isn't a big server somewhere.

My suggestion would be to install apache or some other small web server on each users computer and have have a dyndns address for each computer so you can find each other. it would be much easier than coding something. especially if it has to be through a web page.

Upvotes: 0

Related Questions