开发无服务器 LAN 聊天程序帮助!
我想开发简单的无服务器局域网聊天程序只是为了好玩。 我怎样才能做到这一点 ? 我应该使用什么类型的架构?
去年我参与了 TCP,UDP 客户端/服务器应用程序项目。它很简单(服务器侦听某些端口/套接字,客户端连接到服务器的端口等。)但我不知道如何开发“无服务器”局域网聊天程序。 我怎样才能做到这一点? UDP、TCP、组播、广播? 或者程序的行为应该像服务器和客户端一样吗?
I want to develop simple Serverless LAN Chat program just for fun. How can I do this ? What type Architecture should I use?
Last year I have worked on TCP,UDP Client/ Server application Project.It was simple (Server listens to certain port/socket and Client connect to server's port etc..) But I have no idea about how to develop "Serverless" LAN Chat program. How can I do this? UDP,TCP,Multicast,Broadcast? or Should program behave like both server and client?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最简单的方法是使用 UDP 并在整个网络上广播您的消息。
更高级的版本是仅使用广播来发现网络中的其他节点。
您还必须考虑处理节点的退出,而不让它们通知网络的其余部分。
The simplest way would be to use UDP and simply broadcast your messages all over the network.
A little bit more advanced version would be to only use the broadcast to discover other nodes in the network.
You would also have to consider handling the dropping out of nodes without them informing the rest of the network.
spread 工具包对于你想要的东西来说可能有点大材小用,但却是一个有趣的起点。
从简介中可以看出:
Spread 是一个开源工具包,它提供高性能的消息传递服务,能够适应局域网和广域网的故障。 Spread 充当分布式应用程序的统一消息总线,并提供高度调整的应用程序级多播、组通信和点对点支持。 传播服务范围从可靠的消息传递到具有交付保证的完全有序的消息。
Spread 可用于许多需要高可靠性、高性能以及各个成员子集之间强大通信的分布式应用程序。 该工具包旨在封装异步网络的挑战性方面,并支持构建可靠且可扩展的分布式应用程序。
Spread 由一个与用户应用程序链接的库、一个在属于处理器组的每台计算机上运行的二进制守护程序以及各种实用程序和演示程序组成。
Spread 提供的一些服务和优势:
The spread toolkit may be a bit overkill for what you want, but an interesting starting point.
From the blurb:
Spread is an open source toolkit that provides a high performance messaging service that is resilient to faults across local and wide area networks. Spread functions as a unified message bus for distributed applications, and provides highly tuned application-level multicast, group communication, and point to point support. Spread services range from reliable messaging to fully ordered messages with delivery guarantees.
Spread can be used in many distributed applications that require high reliability, high performance, and robust communication among various subsets of members. The toolkit is designed to encapsulate the challenging aspects of asynchronous networks and enable the construction of reliable and scalable distributed applications.
Spread consists of a library that user applications are linked with, a binary daemon which runs on each computer that is part of the processor group, and various utility and demonstration programs.
Some of the services and benefits provided by Spread:
Apple 的 iChat 正是您所设想的产品的一个例子。 它使用 Bonjour(苹果的零配置网络协议)来识别 LAN 上的对等点。 然后您可以与他们聊天或音频/视频聊天。
我不完全确定 Bonjour 内部是如何工作的,但我知道它使用多播。 客户端在 LAN 上“注册”服务,Bonjour 协议允许每个主机为给定服务提取主机目录(所有这些都无需集中管理)。
Apples iChat is an example of the very product you are envisioning. It uses Bonjour (apple's zero-conf networking protocol) to identify peers on a LAN. You can then chat or audio/video chat with them.
I'm not entirely sure how Bonjour works inside, but I know it uses multicast. Clients "register" services on the LAN, and the Bonjour protocol allows for each host to pull up a directory of hosts for a given service (all without central management).