有没有高级、简单的 IPC 库
是否有适用于 C# 的高级、简单的 IPC 库?似乎大多数帖子都指向使用 WCF。但这看起来比我需要的要复杂得多。我只想在两个 C# 应用程序之间发送异步消息,这两个应用程序可能位于也可能不在同一系统上。
我希望存在一些像下面这样简单易用的东西,它只需要一个 Send 和一个 OnRead 命令。 (链接是我希望存在的IPC库)。
private void StartServer()
{
using (var link = new Link("InstanceName"))
{
link.OnRead += delegate(Link client, object data)
{
client.Send("Echoing " + data);
};
link.Connect();
Console.WriteLine("Press any key to stop the server.");
Console.ReadKey();
}
}
private void StartClient()
{
using (var link = new Link("serverName", "InstanceName"))
{
link.OnRead += delegate(Link server, object data) { Console.WriteLine(data); };
link.Connect();
link.Send("Hello There!");
Console.WriteLine("Press any key to stop the client.");
Console.ReadKey();
}
}
Are there any high level, simple IPC libraries for C#? It seems most posts point to using WCF. But this looks far more complicated than I need. I just want to send asynchronous messages between two C# apps that may or may not be on the same system.
I am hoping something exists that is as simple to use as the following which comes down to just a Send and an OnRead command. (Link is the IPC library I hope exists).
private void StartServer()
{
using (var link = new Link("InstanceName"))
{
link.OnRead += delegate(Link client, object data)
{
client.Send("Echoing " + data);
};
link.Connect();
Console.WriteLine("Press any key to stop the server.");
Console.ReadKey();
}
}
private void StartClient()
{
using (var link = new Link("serverName", "InstanceName"))
{
link.OnRead += delegate(Link server, object data) { Console.WriteLine(data); };
link.Connect();
link.Send("Hello There!");
Console.WriteLine("Press any key to stop the client.");
Console.ReadKey();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
自托管 WCF 就很接近了。
Self-hosted WCF would come close.
您可以查看我们的 MsgConnect,它完全满足您的需求,并且适用于包括 .NET 在内的许多平台。 MsgConnect 的设计灵感来自 Windows API - PostMessage/SendMessage/GetMessage 函数,但 MsgConnect 具有 Socket 传输功能,可让您通过网络发送消息。安装包中提供了示例。
You can take a look at our MsgConnect which offers exactly what you need and for many platforms including .NET. Design of MsgConnect is inspired by Windows API - PostMessage/SendMessage/GetMessage functions, yet MsgConnect has Socket transport which lets you send messages across network. Samples are available in the installation package.