与 LAN 上的应用程序通信

发布于 2024-10-09 22:09:51 字数 186 浏览 2 评论 0 原文

我想编写一个具有娱乐目的的应用程序。这应该是一个桌面应用程序,它检测自己在同一 LAN 上的其他计算机上运行并与它们通信。我所说的沟通是指我应该能够将任何东西传递给另一个人。

请注意,虽然我不要求代码(当然,这会超出我的目的),但我认为一些小片段不会有什么坏处。无论如何,我真正想要的是“推荐的过程”,我的意思是微软对此环境的推荐以及文档:)

I want to code an app with recreational purposes. This should be a Desktop app that detects itself running on other computers on the same LAN and communicates with them. By communication I mean that I should be able to pass anything from on to another.

Please note that although I'm not asking for code (that would beat my purpose, of course) I think some small snippets wouldn't hurt. In any case what I really want is the "recommended procedure", I mean what Microsoft recommends for this environment, and documentation :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不寐倦长更 2024-10-16 22:09:51

如果这是您的第一个网络应用程序,您应该从套接字开始,这样您就可以理解并理解从头开始构建这样的应用程序所涉及的问题。实际上,您尝试构建的是一个点对点应用程序。您需要在这里考虑和研究很多事情,例如:

  1. 对等发现 - 检测网络上的其他实例并确定它们是否仍然在线
  2. 消息传递 - 为您的应用程序设计在线协议
  3. 安全性——例如加密、防止重放

最终(一旦您理解了基本概念),您将希望将所有这些都推迟到框架中,而不是从头开始开发所有内容 我认为 WCF 对等 会满足您的需求。

If this is your first ever network application, you should start with sockets so you can understand and appreciate the issues involved in building an app like this from scratch. Effectively, what you are trying to build is a peer-to-peer application. There are many things you'll want to think about and research here, like:

  1. Peer discovery -- detecting other instances on the network and figuring out if they're still online or not
  2. Messaging -- designing an on the wire protocol for your app
  3. Security -- things like encryption, preventing replay
    attacks, etc.

Eventually (once you've understood the underlying concepts), you will want to defer all of this to a framework rather than developing everything from scratch. I think WCF peer-to-peer will fit your needs.

懒的傷心 2024-10-16 22:09:51

正如 Taz 所说,套接字编程是最好的选择,但您可以使用其他解决方案,例如 WCF(通常不推荐)。

关于在LAN上查找其他实例,我可以说您需要一些扫描算法。大多数蠕虫病毒都有这样的传播算法。您应该考虑许多网络问题,例如目标 LAN 上的开放端口和防火墙限制。

另一点可以使用超过 5000 的 TCP 端口(最多 65535,但不要使用著名端口),因为 5000 以下的端口可能会被操作系统使用。

还需要您自己的 TCP/IP 协议用于对等点之间的消息传递/命令和数据传输。

最后,在此类项目中获得网络/安全顾问的帮助是个好主意,因为您遇到的大多数问题与编程无关,而是与网络有关。

As Taz said socket programming is the best choice but you can use other solutions like WCF (not recommended normally).

About finding other instances on the LAN I could say you need some scanning algorithm. Most worms have such an algorithm for spreading. You should consider many networking issues like open ports on target LAN and firewall restrictions.

Another point could using a TCP port over 5000 (up to 65535, but don't use famous ports) since ports under 5000 are subject to be used by operating system.

Also to need your own protocol over TCP/IP for messaging/commanding and data transfer between peers.

At the end it's a good idea to have a hand from a networking/security consultant in this kind of projects since most problems you encounter are not about programming but networking.

满栀 2024-10-16 22:09:51

套接字编程?让它们侦听特定端口,每当应用程序启动时,它都应该连接到该套接字,并且它们都已连接。我不确定应用程序应如何搜索在 LAN 上运行的其他应用程序实例。

Socket programming? Make them listen on a specific port and whenever application starts it should connect to that socket and the they are both connected. I am not sure how should application search for other application instances running on LAN.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文