ZeroMQ C# namespace (.NET and mono, Windows, Linux and MacOSX, x86 and amd64)
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Devices Updating ZDevices: ZContext.Current Sep 17, 2015
Monitoring Fixed deadlock when ZMonitor was stopped via closing the context Jul 11, 2017
ZeroMQTest Updating .mono.csproj Sep 11, 2017
amd64 Problem: no dylib files included Sep 18, 2017
i386 Problem: no dylib files included Sep 18, 2017
lib Updating ZeroMQ.lib.Platform... Now just using default DllImports. (#142 Nov 9, 2017
.gitignore Updating Version, NuGet Package, .gitignore and .zip.sh Sep 9, 2017
.travis.yml Problem: repository binaries are always overwritten by macports Sep 19, 2017
AssemblyInfo.cs Updating ZeroMQ.nuspec, v4.1.0.26 Sep 22, 2017
LICENSE.txt Adding LICENSE Feb 18, 2015
README.md Problem: unclear specification of supported build and execution Sep 8, 2017
RouterMandatory.cs EOL changed to Windows, Space to Tab, Formatting Jan 6, 2015
TcpKeepaliveBehaviour.cs EOL changed to Windows, Space to Tab, Formatting Jan 6, 2015
Z85.cs Problem: buffer allocated as dest for the call to zmq_z85_encode is o… May 15, 2017
ZActor.cs Updating ZContext.Current, Updating ZSocket (-1: false, *: true) Oct 10, 2015
ZContext.cs Problem: There are CA1063 warnings related to the implementation of I… May 17, 2017
ZContextOption.cs Updating ZContextOption Aug 20, 2015
ZDevice.cs Updating ZContext.Current, Updating ZSocket (-1: false, *: true) Oct 10, 2015
ZError.cs Added more MacOS X error code overrides Jun 29, 2017
ZException.cs Updating ZException.cs: making new ZException(int) public again Sep 6, 2017
ZFrame.cs Problem: There are CA1063 warnings related to the implementation of I… May 17, 2017
ZFrameOption.cs Updating ZFrame, ZFrameOption Feb 16, 2015
ZMessage.cs Rewind ZFrames on ZMessage.Pop Jul 5, 2017
ZPoll.cs EOL changed to Windows, Space to Tab, Formatting Jan 6, 2015
ZPollItem.cs Improving ZPollItem Jan 22, 2015
ZPollItems.Posix.cs Updating EINTR Feb 12, 2015
ZPollItems.Win32.cs Improving ZPollItem, ZPollItems, .Posix and .Windows Jan 22, 2015
ZPollItems.cs Updating ZeroMQ.lib.Platform... Now just using default DllImports. (#142 Nov 9, 2017
ZSocket.cs Merge pull request #97 from sigiesec/more-tests Jun 1, 2017
ZSocketFlags.cs EOL changed to Windows, Space to Tab, Formatting Jan 6, 2015
ZSocketOption.cs Updating ZSocketOption: Adding New Options Sep 17, 2015
ZSocketSetup.cs Updating ZSocketSetup Jun 3, 2015
ZSocketType.cs Updating ZSocketType Mar 24, 2015
ZSymbol.cs Fixed error codes for Windows (for current Windows SDKs) Jun 7, 2017
ZThread.cs Problem: Test case ZMonitorTest.Create fails Sep 8, 2017
ZeroMQ.7z.Release.cmd Updating ZeroMQ.7z.*.cmd Feb 9, 2015
ZeroMQ.VS.csproj Updating ZeroMQ.lib.Platform... Now just using default DllImports. (#142 Nov 9, 2017
ZeroMQ.gif Updating ZeroMQ.ico Feb 4, 2015
ZeroMQ.ico Updating ZeroMQ.ico Feb 4, 2015
ZeroMQ.mono.csproj Updating ZeroMQ.lib.Platform... Now just using default DllImports. (#142 Nov 9, 2017
ZeroMQ.nuspec Updating ZeroMQ.nuspec, v4.1.0.26 Sep 22, 2017
ZeroMQ.snk Initial Release of ZeroMQ CLR namespace Dec 25, 2014
ZeroMQ.targets Updating Version, NuGet Package, .gitignore and .zip.sh Sep 9, 2017
ZeroMQ.zip.Release.sh Updating Version, NuGet Package, .gitignore and .zip.sh Sep 9, 2017
app.config Updating App.config for MacOSX Nov 12, 2017
appveyor.yml Increase nuget verbosity Jul 5, 2017
build.sh Problem: repository binaries are always overwritten by macports Sep 19, 2017
clrzmq4.VS.sln Fixed solution file syntax May 20, 2017
clrzmq4.mono.sln Update clrzmq4.mono.sln Sep 11, 2017
install_deps.sh Problem: repository binaries are always overwritten by macports Sep 19, 2017
test.ps1 Publish only ZeroMQ package Jul 4, 2017
upload_coverage.ps1 Syntax fix Jul 4, 2017

README.md

Build status Build Status Coverage Status

ZeroMQ C# library

clrzmq4 is a .NET wrapper around the native ZeroMQ/libzmq library, and provides the ZeroMQ namespace.

It is written in C# 5.0, and can be built using Visual Studio 2012+ and Mono 5+.

It is built as AnyCPU to run on .NET Framework 4.0+ and mono 5+, and can currently load native shared libraries for i386 and amd64 on Windows, GNU/Linux and Mac OS X.

The pre-built binary packages include native shared libraries for Windows (libzmq 4.2.2) and GNU/Linux (libzmq 4.1.7), for the i386 and amd64 architectures. You can replace the native shared libraries, any libzmq 4.x should work.

Get it

Read ZeroMQ - The Guide

Ask questions on stackoverflow using tags C# ZeroMQ !

HWClient Example

public static void HWClient(string[] args)
{
	//
	// Hello World client
	//
	// Author: metadings
	//

	// Create
	// using (var context = new ZContext())
	using (var requester = new ZSocket(ZSocketType.REQ))
	{
		// Connect
		requester.Connect("tcp://127.0.0.1:5555");

		for (int n = 0; n < 10; ++n)
		{
			string requestText = "Hello";
			Console.Write("Sending {0}...", requestText);

			// Send
			requester.Send(new ZFrame(requestText));

			// Receive
			using (ZFrame reply = requester.ReceiveFrame()) 
			{
				Console.WriteLine(" Received: {0} {1}!", requestText, reply.ReadString());
			}
		}
	}
}

HWServer Example

public static void HWServer(string[] args)
{
	//
	// Hello World server
	//
	// Author: metadings
	//

	if (args == null || args.Length < 1)
	{
		Console.WriteLine();
		Console.WriteLine("Usage: ./{0} HWServer [Name]", AppDomain.CurrentDomain.FriendlyName);
		Console.WriteLine();
		Console.WriteLine("    Name   Your name. Default: World");
		Console.WriteLine();
		args = new string[] { "World" };
	}

	string name = args[0];

	// Create
	// using (var context = new ZContext())
	using (var responder = new ZSocket(ZSocketType.REP))
	{
		// Bind
		responder.Bind("tcp://*:5555");

		while (true)
		{
			// Receive
			using (ZFrame request = responder.ReceiveFrame())
			{
				Console.WriteLine("Received {0}", request.ReadString());

				// Do some work
				Thread.Sleep(1);

				// Send
				responder.Send(new ZFrame(name));
			}
		}
	}
}

WUClient Example

public static void WUClient(string[] args)
{
	//
	// Weather update client
	// Connects SUB socket to tcp://localhost:5556
	// Collects weather updates and finds avg temp in zipcode
	//
	// Author: metadings
	//

	if (args == null || args.Length < 2)
	{
		Console.WriteLine();
		Console.WriteLine("Usage: ./{0} WUClient [ZipCode] [Endpoint]", AppDomain.CurrentDomain.FriendlyName);
		Console.WriteLine();
		Console.WriteLine("    ZipCode   The zip code to subscribe. Default is 72622 Nürtingen");
		Console.WriteLine("    Endpoint  Where WUClient should connect to.");
		Console.WriteLine("              Default is tcp://127.0.0.1:5556");
		Console.WriteLine();
		if (args.Length < 1)
			args = new string[] { "72622", "tcp://127.0.0.1:5556" };
		else
			args = new string[] { args[0], "tcp://127.0.0.1:5556" };
	}

	// Socket to talk to server
	// using (var context = new ZContext())
	using (var subscriber = new ZSocket(ZSocketType.SUB))
	{
		string connect_to = args[1];
		Console.WriteLine("I: Connecting to {0}...", connect_to);
		subscriber.Connect(connect_to);

		// Subscribe to zipcode
		string zipCode = args[0];
		Console.WriteLine("I: Subscribing to zip code {0}...", zipCode);
		subscriber.Subscribe(zipCode);

		// Process 10 updates
		int i = 0;
		long total_temperature = 0;
		for (; i < 20; ++i)
		{
			using (var replyFrame = subscriber.ReceiveFrame())
			{
				string reply = replyFrame.ReadString();

				Console.WriteLine(reply);
				total_temperature += Convert.ToInt64(reply.Split(' ')[1]);
			}
		}
		Console.WriteLine("Average temperature for zipcode '{0}' was {1}°", zipCode, (total_temperature / i));
	}
}

WUServer Example

public static void WUServer(string[] args)
{
	//
	// Weather update server
	// Binds PUB socket to tcp://*:5556
	// Publishes random weather updates
	//
	// Author: metadings
	//

	// Prepare our (context and) publisher
	// using (var context = new ZContext())
	using (var publisher = new ZSocket(ZSocketType.PUB))
	{
		string address = "tcp://*:5556";
		Console.WriteLine("I: Publisher.Bind'ing on {0}", address);
		publisher.Bind(address);

		// Initialize random number generator
		var rnd = new Random();

		while (true)
		{
			// Get values that will fool the boss
			int zipcode = rnd.Next(99999);
			int temperature = rnd.Next(-55, +45);

			// Send message to all subscribers
			var update = string.Format("{0:D5} {1}", zipcode, temperature);
			using (var updateFrame = new ZFrame(update))
			{
				publisher.Send(updateFrame);
			}
		}
	}
}

Also look into the WUProxy Example.

Learn more: ZeroMQ - The Guide and the Examples in C#