Skip to content
ZeroMQ C# namespace (.NET and mono, Windows, Linux and MacOSX, x86 and amd64)
C# Other
  1. C# 99.5%
  2. Other 0.5%
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Devices New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
Monitoring New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
Platform Updating ZeroMQ/clrzmq4: .NET Standard and Core compatability Mar 9, 2019
ZGuideExamples Adding ZeroMQ/clrzmq4 and ZGuideExamples/project.json Mar 10, 2019
.gitignore Adding ZeroMQ/clrzmq4 and ZGuideExamples/project.json Mar 10, 2019
.travis.yml Updating .travis.yml, appveyor.yml Feb 16, 2019
AssemblyInfo.cs Updating ZeroMQ/clrzmq4: nuget v4.1.0.31 Mar 13, 2019
LICENSE.txt New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
README.md Problem: manual hack in README for libzmq.so Jul 1, 2019
RouterMandatory.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
TcpKeepaliveBehaviour.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
Z85.cs Updating Z85.En/Decode: Now IronhouseClient/Server is working Mar 9, 2019
ZActor.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZAuth.cs Fixed wrong format in XML comment Mar 9, 2019
ZCert.cs Ported ZAuth, ZCert and ZCertStore from CZQM to enable authentication… Mar 9, 2019
ZCertStore.cs Ported ZAuth, ZCert and ZCertStore from CZQM to enable authentication… Mar 9, 2019
ZContext.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZContextOption.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZDevice.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZError.cs Removing libsodium from Platform/zmq.cs - use tweetnacl instead Mar 9, 2019
ZException.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZFrame.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZFrameOption.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZMessage.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZPoll.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZPollItem.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZPollItems.Posix.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZPollItems.Win32.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZPollItems.cs Removing libsodium from Platform/zmq.cs - use tweetnacl instead Mar 9, 2019
ZSocket.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZSocketFlags.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZSocketOption.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZSocketSetup.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZSocketType.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZSymbol.cs Updating ZeroMQ/clrzmq4: .NET Standard and Core compatability Mar 9, 2019
ZThread.cs New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZeroMQ.7z.Release.cmd New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZeroMQ.gif New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZeroMQ.ico New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZeroMQ.mono.csproj Updating ZeroMQ/clrzmq4: .NET Standard and Core compatability Mar 9, 2019
ZeroMQ.netcore.csproj Updating README.md and .netcore.csproj Mar 9, 2019
ZeroMQ.nuspec Updating ZeroMQ/clrzmq4: nuget v4.1.0.31 Mar 13, 2019
ZeroMQ.snk New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
ZeroMQ.targets
ZeroMQ.vs.csproj Updating ZeroMQ/clrzmq4: .NET Standard and Core compatability Mar 9, 2019
ZeroMQ.zip.Release.sh New Initial Release, without binary folder i386/ and amd64/ Feb 14, 2019
app.config Updating ZGuideExamples, build.sh Feb 15, 2019
appveyor.yml Updating appveyor.yml, Platform.Win32.cs Feb 16, 2019
build.sh Updating ZGuideExamples, build.sh Feb 15, 2019
clrzmq4.mono.sln Removing ZeroMQTest entierly. It depends on NUnit: do return 0 (good)… Mar 9, 2019
clrzmq4.netcore.sln Updating ZeroMQ/clrzmq4: .NET Standard and Core compatability Mar 9, 2019
clrzmq4.vs.sln Removing ZeroMQTest entierly. It depends on NUnit: do return 0 (good)… Mar 9, 2019
project.json Adding ZeroMQ/clrzmq4 and ZGuideExamples/project.json Mar 10, 2019
travis.preinstall.sh Updating .travis.yml, appveyor.yml Feb 16, 2019

README.md

Build Status Build 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 opened and built using Visual Studio 2012+ and MonoDevelop 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 nuget.org/packages/ZeroMQ/ includes native shared libraries for Windows (libzmq 4.1.n) and GNU/Linux (libzmq 4.1.n), for Windows i386 and linux/MacOSX x86_64 architectures.

You can place any native shared library or dynamic link libraries into a folder ~/Downloads/clrzmq4/amd64 or ~/Downloads/clrzmq4/i386, any libzmq.dll/.so/.dylib 3.x 4.x will work, important is just that the file name is libzmq.dll.

    sudo apt-get install libzmq3-dev

Get it

Open it

  • using MonoDevelop or Visual Studio
  • using Texteditor gedit or GNU emacs

Run it

  • You can't run ZeroMQ/clrzmq4 directly, because this is a library.
  • using mono framework:
msbuild clrzmq4.mono.sln /p:Configuration=Release
mono bin/Release/ZGuideExamples.exe Espresso
  • using dotnet framwork
nuget restore clrzmq4.netcore.sln
dotnet msbuild clrzmq4.netcore.sln
dotnet run --project ZGuideExamples/ZGuideExamples.netcore.csproj Espresso

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#

You can’t perform that action at this time.