在Java中开发Peer to Peer应用程序 [英] Developing Peer to Peer application in Java

查看:679
本文介绍了在Java中开发Peer to Peer应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大学项目,我需要在java中开发一个点对点系统来进行文件共享。

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??

推荐答案

对于大学项目,阅读一些关于套接字的教程。我相信这就是你的教授所期待的。例如,以下内容: http://www.oracle.com/technetwork/java /socket-140484.html

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

有两种通用解决方案:服务器已满和无服务器。如果是基于服务器的解决方案,则应使用服务器的IP地址预先配置所有客户端。服务器打开服务器套接字并开始监听因此,每个客户端都连接到服务器和寄存器。注册非常简单:服务器只需要客户端的IP。现在,服务器保存已连接客户端的列表,并将列表发送到每个客户端。要使peer2peer应用程序,每个客户端也打开服务器套接字。当客户端A希望连接到客户端B时,它只是连接到其套接字。

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.

这篇关于在Java中开发Peer to Peer应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆