且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用c#向远程PC发送消息

更新时间:2021-12-07 22:10:05

很明显,您不能只在任何地方发送消息 。您总是需要在两台主机上发送和接收一些应用程序。通常情况下,其中一方是Windows服务,当涉及到Windows(C#不仅用于Windows,它可以在许多不同平台上实现的CLR中使用,包括非Microsoft)。



软件的通信部分可以在不同级别创建,从原始套接字到.NET网络到WCF,自托管或不托管。我在过去的答案中提供了这些级别的简短概述:

我如何将byte []发送到其他电脑 [ ^ ],

通信b / w局域网上的两个Windows应用程序。 [ ^ ]。



您可以选择任何一种方法;它可能取决于许多因素,不仅仅是要求,甚至是你的经验和个人品味。



-SA
It''s apparent that you cannot just "send message" anywhere. You always need some applications on both hosts, sending and receiving. Typically enough, one of the sides is a Windows Service, when it comes to Windows (C# is used not only on Windows, it can be used in CLR implemented on many different platforms, including non-Microsoft).

The communication part of software can be created on different levels, from raw sockets to .NET networking to WCF, self-hosted or not. I provided short overviews of those levels in my past answers:
how i can send byte[] to other pc[^],
Communication b/w two Windows applications on LAN.[^].

You can select any of the approaches; it may depends on many factors, not only requirements, but even your experience and personal taste.

—SA