[zeromq-dev] What's wrong with my client XREQ

Pieter Hintjens pieterh at gmail.com
Mon Aug 29 16:27:19 CEST 2011


Please read the documentation for router sockets (man zmq_socket) and the
Guide ch2 and ch3.

- Pieter
On Aug 29, 2011 2:16 PM, "ZOUNG KALACK Jimy (EXT)" <
jimy.zoung-kalack-ext at sgcib.com> wrote:
> I've got a client, a broker and a server.
> The server sends 1000 times the same message. The message is Hello
> The client should read all the messages as they arrive.
>
> Nothing is coming to the client and I don't know why?
> Maybe I'm doing something wrong in the client.
>
> static void ClientTask()
> {
> using (Context ctx = new Context(1))
> {
> using (Socket client = ctx.Socket(SocketType.XREQ))
> {
> client.Connect("tcp://localhost:5570");
> Console.WriteLine("Client starts");
>
> PollItem[] items = new PollItem[1];
> items[0] = client.CreatePollItem(IOMultiPlex.POLLIN);
> items[0].PollInHandler += (skt, revents) =>
> {
> ZMessage zmsg = new ZMessage(skt);
> Console.WriteLine("received {0} ", zmsg.BodyToString());
>
>
> while (true)
> {
> ctx.Poll(items, 1000);
> }
> }
> }
> }
>
> static void Main(string[] args)
> {
> Thread client = new Thread(ClientTask);
> client.Start();
>
> }
>
> ---------------------------------------------------
> sender
> -----------------------------------------------
> static void Main(string[] args)
> {
> using (Context ctx = new Context(1))
> {
> using (Socket worker = ctx.Socket(SocketType.XREP))
> {
> worker.Connect("tcp://localhost:5571");
> for(int i=0;i<1000;i++)
> {
>
> ZMessage zmsg = new ZMessage("Hello");
> zmsg.Send(worker);
> Console.WriteLine("reply back " + zmsg.BodyToString());
>
> }
> }
> }
> }
>
>
> ----------------------------------------
> broker
> -----------------------------------------
> namespace BrokerQueue
> {
> class Program
> {
> static void Main(string[] args)
> {
> using (Context context = new Context(1))
> {
> using (Socket frontend = context.Socket(SocketType.XREP),
> backend = context.Socket(SocketType.XREQ))
> {
> // Socket facing clients
> frontend.Bind("tcp://*:5570");
> Console.WriteLine("Broker frontend: bind to Client");
>
> // Backend socket talks to workers over inproc
> backend.Bind("tcp://*:5571");
> Console.WriteLine("bind backend");
>
> // Start built-in device
> Socket.Device.Queue(frontend, backend);
> }
> }
> }
> }
> }
> *************************************************************************
> This message and any attachments (the "message") are confidential,
intended solely for the addressee(s), and may contain legally privileged
information.
> Any unauthorised use or dissemination is prohibited. E-mails are
susceptible to alteration.
> Neither SOCIETE GENERALE nor any of its subsidiaries or affiliates shall
be liable for the message if altered, changed or
> falsified.
> ************
> Ce message et toutes les pieces jointes (ci-apres le "message") sont
confidentiels et susceptibles de contenir des informations couvertes
> par le secret professionnel.
> Ce message est etabli a l'intention exclusive de ses destinataires. Toute
utilisation ou diffusion non autorisee est interdite.
> Tout message electronique est susceptible d'alteration.
> La SOCIETE GENERALE et ses filiales declinent toute responsabilite au
titre de ce message s'il a ete altere, deforme ou falsifie.
> *************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110829/ba61b54f/attachment.htm>


More information about the zeromq-dev mailing list