虽然你说 TCP 已经出...
我一直非常热衷于使用 ZeroMQ,但一直没有机会。它是带有 ac# 包装器的多平台,专为此类应用程序消息传递而设计。在http://www.zeromq.org/查看 ZeroMQ 。
他们网站之一的一些示例代码:
// Set up a publisher.
var publisher = new ZmqPublishSocket {
Identity = Guid.NewGuid().ToByteArray(),
RecoverySeconds = 10
};
publisher.Bind( address: "tcp://127.0.0.1:9292" );
// Set up a subscriber.
var subscriber = new ZmqSubscribeSocket();
subscriber.Connect( address: "tcp://127.0.0.1:9292" );
subscriber.Subscribe( prefix: "" ); // subscribe to all messages
// Add a handler to the subscriber's OnReceive event
subscriber.OnReceive += () => {
String message;
subscriber.Receive( out message, nonblocking: true );
Console.WriteLine( message );
};
// Publish a message to all subscribers.
publisher.Send( "Hello world!" );