[zeromq-dev] C#Client

Martin Hurton hurtonm at gmail.com
Mon Jul 20 09:06:44 CEST 2009


On Fri, Jul 17, 2009 at 3:57 PM, Daniele Teti<d.teti at bittime.it> wrote:
> I'm still research a way to use ZeroMQ in Delphi.
>
> But I want to check my installation and my ZeroMQ knowledge, so I wrote a
> simple test program in C#.
> But... doesn't work!
>
> Please, can somewone check my code?
> (zmq_server.exe is runing without parameters)
>
> using System;
> using System.Collections.Generic;
> using System.Linq;
> using System.Text;
>
> namespace ConsoleApplication1
> {
>     class Program
>     {
>         public static byte[] StrToByteArray(string str)
>         {
>             System.Text.ASCIIEncoding encoding = new
> System.Text.ASCIIEncoding();
>             return encoding.GetBytes(str);
>         }
>         static void Main(string[] args)
>         {
>
>             Zmq zmq = new Zmq("127.0.0.1");
>             int ex = zmq.CreateExchange("daniele", Zmq.SCOPE_LOCAL, "",
> Zmq.STYLE_DATA_DISTRIBUTION);
>             int q = zmq.CreateQueue("paperino", Zmq.SCOPE_LOCAL, "",
> Zmq.NO_LIMIT, Zmq.NO_LIMIT, Zmq.NO_LIMIT);
>             zmq.Bind("daniele", "paperino", "", "");
>             zmq.Send(ex, StrToByteArray("daniele"), true);

I do not understand why you invalidate the zmq pointer and then set up
the new zmq context. Also, you create both the exchange and the queue
as local so you cannot reach them from other zmq context.

Maybe you can get some ideas from the chat example (located in
examples/chat directory).

Regards,
Martin

>             zmq = null;
>
>             zmq = new Zmq("127.0.0.1");
>             ex = zmq.CreateExchange("daniele", Zmq.SCOPE_LOCAL, "",
> Zmq.STYLE_DATA_DISTRIBUTION);
>             q = zmq.CreateQueue("paperino", Zmq.SCOPE_LOCAL, "",
> Zmq.NO_LIMIT, Zmq.NO_LIMIT, Zmq.NO_LIMIT);
>             zmq.Bind("daniele", "paperino", "", "");
>             byte[] pippo;
>             int theType;
>             zmq.Receive(out pippo, out theType, true);
>             zmq = null;
>         }
>     }
> }
>
>
> --
> Daniele Teti
> R&D Director & Educational
> bit Time Software
> www.bittime.it
> www.danieleteti.it
> www.codegear.it
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>



More information about the zeromq-dev mailing list