24

i've got a university project where i need to develop a peer to peer system in java for file sharing.

So in essence several users should be able to share files using the Peer to Peer System.

Can someone give me some guidelines about how to build this system??

Noor
  • 19,638
  • 38
  • 136
  • 254
  • 3
    I suggest you have a look at one of the many open source implementations of peer to peer file sharing and use these as a template (or just use them as they are) – Peter Lawrey Feb 07 '11 at 11:08

2 Answers2

21

For university project read some tutorial about sockets. I believe that this is what your professor is expecting from you. Take for example the following: http://www.oracle.com/technetwork/java/socket-140484.html

There are 2 general solutions: server-full and server-less. In case of server based solutions all your clients should be pre-configured with the server's IP address. Server opens server socket and starts listening. So, each client connects to server and registers. The registration is very simple: server just needs the client's IP. Now server holds a list of connected clients and sends the list to each client. To make peer2peer app each client opens server socket too. When client A wishes to connect to client B it just connects to its socket.

You can implement server-less solution. In this case you need some discovery mechanism based for example on broadcasting.

I hope this helps. Good luck.

AlexR
  • 114,158
  • 16
  • 130
  • 208
  • how about the client that doesn't know the server IP address? Since (all devices) they're not connected yet into any networks? I'm proposing wifi communication for them. But would it be possible? – gumuruh Jul 06 '14 at 02:49
  • Wifi is just a way to connect to TCP/IP world. If client does not know the server's IP you need some kind of discovery mechanism. For example brodcast. But this is possible in closed networks only. – AlexR Jul 06 '14 at 05:43
  • is that mean it is impossible for two android devices to communicate on WIFI that already turning on their WIFI (but not connected to any networks) -no internet, no bluetooth, no phonecell data? I though java / android could broadcast its simple string over wifi? @AlexR – gumuruh Jul 06 '14 at 05:46
  • I guess they can, but I am not familiar with Android API. I also do not exactly understand how have you make this conclusion from my comment. – AlexR Jul 06 '14 at 05:49
  • because you just said that we need to implement server-client concept for making the communication between devices. And that's true. I'm just wondering how to make one device shout to another device by sending data through wireless signal without any network connectivity connected yet. – gumuruh Jul 06 '14 at 05:59
  • yeah........ It is possible but don't know how to achieve this....... ShareIt and Similar Apps does this both on Desktop and Android – Ravinder Payal Jun 26 '16 at 18:14
6

You want to check JXTA. The site has moved to jxse.kenai.com. The practical JXTA II book has been made available for reading on Scribd.

Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453