[zeromq-dev] 0MQ for C#

Jason Smith jason.nevar.smith at gmail.com
Fri Nov 30 06:18:12 CET 2012


The C# package is going through an update at present to version 3. I would
suggest first of all using the pre release version.

PM> Install-Package clrzmq -Pre

Once you have that installed you simply need to use the new namespace;

using ZeroMQ;

The following C# hello world client will then not compile for you
http://zguide.zeromq.org/cs:hwclient.

update it to look like the following, and follow your nose to update the
server.

*using* *System*;
*using* *System.Text*;
*using* *ZeroMQ*;

*namespace* *ZMQGuide*
{
*internal* *class* *Program*
{
*public* *static* *void* Main(string[] args)
{
*using* (var context = ZmqContext.Create()))
{
*using* (ZmqSocket requester = context.CreateSocket(SocketType.REQ))
{
requester.Connect("tcp://localhost:5555");

*const* string requestMessage = "Hello";
*const* int requestsToSend = 10;

*for* (int requestNumber = 0; requestNumber < requestsToSend;
requestNumber++)
{
Console.WriteLine("Sending request {0}…", requestNumber);
requester.Send(requestMessage, Encoding.Unicode);

string reply = requester.Recv(Encoding.Unicode);
Console.WriteLine("Received reply {0}: {1}", requestNumber, reply);
}
}
}
}
}
}
Note: I did all the above from memory as I don't have an environment with
me at present.

Hope that helps.


On 30 November 2012 12:53, Rico Rojas <rico at rodaddys.com> wrote:

> I'm new to 0MQ, but I have been able to get some good stuff working in
> python.
>
> The problem is for it to be really useful to the current client I want to
> use it for, I need to use it in C#.
>
> My issue is that in the guide all of the examples show
> *using* *ZMQ*;
>
> And the code is all very similar to what I am doing with python.  But I
> can not find anyway to use 0MQ in C# other than clrzmq via NuGet, and with
> this you do using ZeroMQ; and the syntax is different.  What do I have to
> do &| get to be able to use the samples in the Guide?
>
> Cheers,
>
> Rico
>
>
> Riccardo A. Rojas
>
> Director of Trade Systems Development
>
> *rTechTrade Systems*
> The Trade system group of Rodaddy's LLC.
>
> Address:
> 233 East Ogden Avenue
> Suite 113
> Hinsdale, IL 60521
>
> eMail: rico at rTechTradeSystems.com
> M: (630) 776-6962 (*preferred contact Number*)
> O: (630) 560-3150
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20121130/3d7fd948/attachment.htm>


More information about the zeromq-dev mailing list