Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example zeromq usage
public sealed class ZmqEventServer
{
public ZmqEventServer(ZmqPollPool pool, NetworkAddress broadcastAddress, NetworkAddress listenAddress)
{
if (!listenAddress.IsBindable) throw new ArgumentException("listen address must be bindable (i.e. IP address instead of DNS name)");
ZmqSocket broadcast=null;
var broadcastAddr = broadcastAddress.String;
var listenAddr = listenAddress.String;
pool.MarshalAndWait((context, register) =>
{
broadcast = context.CreateSocket(SocketType.PUB);
broadcast.Bind(broadcastAddr);
register(broadcast);
});
pool.MarshalAndWait((context, register) =>
{
var listen = context.CreateSocket(SocketType.PULL);
listen.Bind(listenAddr);
register(listen, datagram => Helper.Send(broadcast, datagram.ToList()));
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.