[zeromq-dev] Friendly IDs
Goswin von Brederlow
goswin-v-b at web.de
Tue Sep 30 08:48:39 CEST 2014
Hi,
you have to implement some form of greeting where a connecting client
says hello to the server. The server then sees the new client and can
remember its zmq identity. In my case I use the identity directly. But
if you want to use names (and not use them as zmq identities) then
include the name in the greeting and have the server keep a map of
name to zmq identity.
In pseudocode:
Client > Qeueue: Hello, my name is Jerry.
Queue: recv: (from 0x4567357) Hello, my name is Jerry.
Queue: Remember: New client 0x4567357 is Jerry
Queue > App: (from Jerry) Jerry says hello
App > Qeueue: (to Jerry) Nice to meet you Jerry
Queue: Lookup: Jerry is 0x4567357
Queue > 0x4567357: Nice to meet you Jerry
MfG
Goswin
On Mon, Sep 29, 2014 at 09:02:24AM -0700, Roberto Ostinelli wrote:
> Hi Goswin,
> Thank you for your reply.
>
> How can the QUEUE know which one of sockets is the recipient that
> corresponds to "Jerry", and how can it route to it?
>
> On Mon, Sep 29, 2014 at 2:21 AM, Goswin von Brederlow <goswin-v-b at web.de>
> wrote:
>
> > On Sun, Sep 28, 2014 at 07:17:39PM -0700, Roberto Ostinelli wrote:
> > > Hello 0mq'ers!
> > > I'm investigating 0MQ and up until know I'm enjoying what I'm seeing.
> > >
> > > As an academical exercise, I'm trying to understand how to build a
> > simple server that can route a REQ to a very specific Socket based on a
> > "friendly name", and receive a RES from it.
> > >
> > > For instance, let's say I have two clients, "Tom" and "Jerry", that
> > somehow authenticate on a server.
> > > I want to be able to have Tom send a REQ specifically to "Jerry", and
> > receive a RES, via a server (i.e. not by a direct connection).
> > >
> > > I've seen the examples on how to create a QUEUE device to route XREQ and
> > XRES, however in these examples there are clients on one side and servers
> > on the other, and when a client sends a request, any server on the other
> > side can provide the response. I'd like to have a way for the client "Tom"
> > to specify that it wants its response from the server "Jerry".
> > >
> > > Can a kind soul point me in the right direction?
> > >
> > > Thank you in advance.
> > > r.
> >
> > What I do in my code is to use the same syntax as ROUTER sockets. You
> > send the recipient "Jerry" as first frame of the message and have the
> > QUEUE device use that frame to direct the rest of the message. In my
> > case the outgoing end is a ROUTER socket to I just pass the whole
> > message on, including the recipient frame and the ROUTER socket sends
> > it the right way.
> >
> > MfG
> > Goswin
More information about the zeromq-dev
mailing list