• Stars
    star
    272
  • Rank 145,968 (Top 3 %)
  • Language
    C#
  • License
    Other
  • Created over 13 years ago
  • Updated over 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CLR (.NET & Mono) binding for 0MQ

clrzmq — Official 0MQ Bindings for .NET and Mono

(Formerly clrzmq2; legacy bindings have moved to clrzmq-old)

This project aims to provide the full functionality of the underlying ZeroMQ API to CLR projects.

Bundled libzmq version: 3.2.2-rc2
Legacy libzmq version supported: 2.2.0 (stable)

Getting Started

The quickest way to get started with clrzmq is by using the NuGet package. The NuGet packages include a copy of the native libzmq.dll, which is required to use clrzmq.

You may also build clrzmq directly from the source. See the Development Environment Setup instructions below for more detail.

To get an idea of how to use clrzmq, have a look at the following example.

Example server

using System;
using System.Text;
using System.Threading;
using ZMQ;

namespace ZMQGuide
{
    class Program
    {
        static void Main(string[] args)
        {
            // ZMQ Context, server socket
            using (ZmqContext context = ZmqContext.Create())
            using (ZmqSocket server = context.CreateSocket(SocketType.REP))
            {
                server.Bind("tcp://*:5555");
                
                while (true)
                {
                    // Wait for next request from client
                    string message = server.Receive(Encoding.Unicode);
                    Console.WriteLine("Received request: {0}", message);

                    // Do Some 'work'
                    Thread.Sleep(1000);

                    // Send reply back to client
                    server.Send("World", Encoding.Unicode);
                }
            }
        }
    }
}

Example client

using System;
using System.Text;
using ZMQ;

namespace ZMQGuide
{
    class Program
    {
        static void Main(string[] args)
        {
            // ZMQ Context and client socket
            using (ZmqContext context = ZmqContext.Create())
            using (ZmqSocket client = context.CreateSocket(SocketType.REQ))
            {
                client.Connect("tcp://localhost:5555");

                string request = "Hello";
                for (int requestNum = 0; requestNum < 10; requestNum++)
                {
                    Console.WriteLine("Sending request {0}...", requestNum);
                    client.Send(request, Encoding.Unicode);

                    string reply = client.Receive(Encoding.Unicode);
                    Console.WriteLine("Received reply {0}: {1}", requestNum, reply);
                }
            }
        }
    }
}

Docs and Tutorials

For more information about 0MQ and clrzmq, see the following resources:

  • The 0MQ Guide is a thorough overview of 0MQ and contains example code for most supported languages, including C#. Examples are stored in a GitHub repository.
  • ZeroMQ via C#: Introduction is an excellent tutorial written by Manar Ezzadeen and offers an in-depth look at various 0MQ patterns implemented in C# with clrzmq.

More tutorials and API documentation are on the way.

Deployment Notes

When using a packaged (NuGet/zip) release on Windows, clrzmq comes bundled with 32- and 64-bit versions of libzmq.dll that have been fully tested with the binding package. The DLLs are embedded as manifest resources in the assembly and are extracted when initially loading the assembly. To accommodate different deployment needs, several output paths may be used.

The libzmq.dll search/extract order is as follows:

  1. libzmq.dll on System Path
    • Allows loading a custom libzmq.dll into system32, %PATH%, etc. (see LoadLibrary for search order)
  2. Extract to assembly path
    • Full path to the currently executing clrzmq.dll
  3. Extract to execution path
    • Full path to the executable calling clrzmq
  4. Extract to temporary path
    • Current user's %TEMP%\clrzmq-x.x.x.x
    • Last ditch fallback: only severly restricted accounts will fail to extract to this path

Tracing

If you run into problems related to loading the native library, you can enable tracing in your application as follows:

  1. Add a trace listener to your application (see TraceListener for an example)
  2. Configure the clrzmq trace switch to use the Info level (3):
<configuration>
  <system.diagnostics>
    <switches>
      <add name="clrzmq" value="3" /><!-- Info -->
    </switches>
  </system.diagnostics>
</configuration>

IIS Deployments

IIS deployments can be complicated due to the many possible identities and privilege levels that may be executing your application. There are a few steps you can take to ensure the bundled native libraries can be properly extracted and used:

  1. At the bare minimum, ensure the Application Pool identity has write access to its %TEMP% folder
  2. Allow write access to your application's bin directory (i.e., the directory containing clrzmq.dll and your application assemblies)
  3. If none of those options are suitable, you will need to obtain a compiled version of libzmq.dll for your platform and extract it to a system path (see LoadLibrary for candidates)

Development Environment

On Windows/.NET, clrzmq is developed with Visual Studio 2010. Mono development is done with MonoDevelop 2.8+.

Windows/.NET

clrzmq depends on libzmq.dll, which will be retrieved automatically via NuGet. If you require a specific version of libzmq, you can compile it from the 0MQ sources.

clrzmq

  1. Clone the source.
  2. Run build.cmd to build the project and run the test suite.
  3. The resulting binaries will be available in /build.

Alternate libzmq (optional)

If you want to use a custom build of libzmq.dll, perform the following steps:

  1. Delete or rename the src/.nuget/packages.config file. This prevent the NuGet package from being retrieved.
  2. Remove any folders matching src/packages/libzmq-* that may have been downloaded previously.
  3. Copy the 32-bit and 64-bit (if applicable) build of libzmq.dll to lib/x86 and lib/x64, respectively.

Note that PGM-related tests will fail if a non-PGM build of libzmq is used.

Mono

NOTE: Mono 2.10.7+ is required for development only, as the NuGet scripts and executables require this version to be present. If you choose to install dependencies manually, you may use any version of Mono 2.6+.

Mono 2.10.7+ configuration

NuGet relies on several certificates to be registered with Mono. The following is an example terminal session (on Ubuntu) for setting this up correctly. This assumes you have already installed Mono 2.10.7 or higher.

$ mozroots --import --sync

$ certmgr -ssl https://go.microsoft.com
$ certmgr -ssl https://nugetgallery.blob.core.windows.net
$ certmgr -ssl https://nuget.org

This should result in a working Mono setup for use with NuGet.

libzmq

Either clone the ZeroMQ repository or download the sources, and then follow the build/install instructions for your platform. Use the --with-pgm option if possible.

clrzmq

  1. Clone the source.
  2. Run nuget.sh, which downloads any dependent packages (e.g., NUnitLite for acceptance tests).
  3. Run make to build the project and run the test suite.
  4. The resulting binaries will be available in /build.

NOTE: clrzmq only supports x86 builds on Mono at this time

Issues

Issues should be logged on the GitHub issue tracker for this project.

When reporting issues, please include the following information if possible:

  • Version of clrzmq and/or how it was obtained (compiled from source, NuGet package)
  • Version of libzmq being used
  • Runtime environment (.NET/Mono and associated version)
  • Operating system and platform (Win7/64-bit, Linux/32-bit)
  • Code snippet demonstrating the failure

Contributing

Pull requests and patches are always appreciated! To speed up the merge process, please follow the guidelines below when making a pull request:

  • Create a new branch in your fork for the changes you intend to make. Working directly in master can often lead to unintended additions to the pull request later on.
  • When appropriate, add to the AcceptanceTests project to cover any new functionality or defect fixes.
  • Ensure all previous tests continue to pass (with exceptions for PGM tests)
  • Follow the code style used in the rest of the project. ReSharper and StyleCop configurations have been included in the source tree.

Pull requests will still be accepted if some of these guidelines are not followed: changes will just take longer to merge, as the missing pieces will need to be filled in.

License

This project is released under the LGPL license, as is the native libzmq library. See LICENSE for more details as well as the 0MQ Licensing page.

More Repositories

1

libzmq

ZeroMQ core engine in C++, implements ZMTP/3.1
C++
8,996
star
2

pyzmq

PyZMQ: Python bindings for zeromq
Python
3,480
star
3

netmq

A 100% native C# implementation of ZeroMQ for .NET
C#
2,822
star
4

jeromq

Pure Java ZeroMQ
Java
2,288
star
5

cppzmq

Header-only C++ binding for libzmq
C++
1,737
star
6

zeromq.js

⚡ Node.js bindings to the ØMQ library
TypeScript
1,371
star
7

czmq

High-level C binding for ØMQ
C
1,110
star
8

zmq.rs

A native implementation of ØMQ in Rust
Rust
1,015
star
9

zyre

Zyre - an open-source framework for proximity-based peer-to-peer applications
C
843
star
10

jzmq

Java binding for ZeroMQ
Java
584
star
11

goczmq

goczmq is a golang wrapper for CZMQ.
Go
552
star
12

php-zmq

ZeroMQ for PHP
C
543
star
13

zeromq4-x

ØMQ 4.x stable release branch - bug fixes only
C++
446
star
14

zmqpp

0mq 'highlevel' C++ bindings
C++
418
star
15

zeromq2-x

ØMQ/2.x distribution
C++
365
star
16

malamute

The ZeroMQ Enterprise Messaging Broker
C
311
star
17

gomq

Pure Go Implementation of a Subset of ZeroMQ
Go
290
star
18

filemq

FileMQ is a publish-subscribe file service based on 0MQ
Java
271
star
19

rbzmq

Ruby binding for 0MQ
C
248
star
20

clrzmq4

ZeroMQ C# namespace (.NET and mono, Windows, Linux and MacOSX, x86 and amd64)
C#
235
star
21

zproto

A protocol framework for ZeroMQ
C
228
star
22

zeromq3-x

ØMQ/3.2 release branch - bug fixes only
C++
228
star
23

JSMQ

Javascript client for ZeroMQ/NetMQ
JavaScript
190
star
24

chumak

Pure Erlang implementation of ZeroMQ Message Transport Protocol.
Erlang
189
star
25

erlzmq2

Erlang binding for 0MQ (v2)
C
165
star
26

libcurve

An encryption and authentication library for ZeroMQ applications
C
161
star
27

zproject

CLASS Project Generator
Shell
142
star
28

lzmq

Lua binding to ZeroMQ
Lua
133
star
29

gitdown

Turn github into your publishing platform
Perl 6
130
star
30

zeromq4-1

ZeroMQ 4.1.x stable release branch - bug fixes only
C++
125
star
31

pyre

Python port of Zyre
Python
116
star
32

exzmq

ZeroMQ for Elixir
Elixir
115
star
33

fszmq

An F# binding for the ZeroMQ distributed computing library. For more information, please visit:
F#
112
star
34

majordomo

Majordomo Project
C
111
star
35

cljzmq

Clojure bindings for ØMQ
Clojure
105
star
36

rfc

ZeroMQ RFC project
C
104
star
37

dafka

Dafka is a decentralized distributed streaming platform
C
101
star
38

gyre

Golang port of Zyre
Go
87
star
39

zwssock

ZeroMQ WebSocket library for CZMQ
C
85
star
40

jszmq

Javascript port of zeromq
TypeScript
76
star
41

libzmtp

Minimal ZMTP implementation in C
C
53
star
42

ingescape

Model-based framework for broker-free distributed software environments. Any language, any OS, web, cloud.
C
52
star
43

zbroker

Elastic pipes
C
50
star
44

czmqpp

C++ wrapper for czmq. Aims to be minimal, simple and consistent.
C++
43
star
45

zeromq.org

ZeroMQ Website
HTML
32
star
46

cookbook

ZeroMQ Cookbook
Python
32
star
47

pyczmq

Python CZMQ bindings
Python
31
star
48

zebra

REST/HTTP to XRAP gateway
C++
26
star
49

zmtpdump

ZeroMQ Transport Protocol packet analyzer
Roff
25
star
50

jeromq-jms

JeroMQ JMS
Java
24
star
51

jzmq-api

A Java ØMQ API for abstracting the various implementations of ZeroMQ Message Transport Protocol
Java
24
star
52

zmq-jni

Simple High Performance JNI Wrapper for ØMQ
Java
22
star
53

perlzmq

version agnostic Perl bindings for zeromq
Perl
22
star
54

zmtp

Stuff related to the ZMTP protocol
C
18
star
55

contiki-zmtp

ZMTP for Contiki OS
C
16
star
56

jyre

Java implementation of ZRE protocol
Java
14
star
57

zccp

ZeroMQ Command & Control Protocol
Go
14
star
58

f77_zmq

Fortran binding for ZeroMQ
C
13
star
59

ztools

Tools for ØMQ auto-builds and API site
Perl
12
star
60

zeps

ZeroMQ Enterprise Publish-Subscribe (ZEPS) **DEPRECATED**
C
12
star
61

mruby-zmq

mruby bindings for libzmq (v4)
C
10
star
62

zeromq2-0

Packaging project for ØMQ/2.0 series
C++
9
star
63

zkernel

z kernel
C
9
star
64

nimczmq

Nim ( http://nim-lang.org/ ) bindings for CZMQ
Nim
6
star
65

curvezmq-java

Java
5
star
66

gozyre

Go bindings for zeromq libzyre - an open-source framework for proximity-based peer-to-peer applications
Go
5
star
67

issues

Issue test cases
C
4
star
68

zdiscgo

CZMQ service discovery zactor with support for Go plugins.
C
4
star
69

jdafka

Dafka protocol implementation in Java
Java
4
star
70

zlabs

Labs project for experimenting with CZMQ
Shell
4
star
71

zeromq-buildbot

A buildbot based regression tester for Zeromq
Python
3
star
72

azmq1-0

v1.0 release of azmq
C++
3
star
73

lyre

Lua port of Zyre
Lua
3
star
74

jeromq3-x

Java
3
star
75

jzmq3-x

Java
2
star
76

zmtp-java

Java
2
star
77

libzmq-relicense

This repo contains information regarding re-licensing libzmq
Python
2
star
78

clrzmq2

Old repository path for clrzmq
2
star
79

libzmq-fuzz-corpora

fuzzers corpus files for libzmq are stored in binary format in this repository
1
star
80

zeromq-download-redirect

HTML
1
star