[zeromq-dev] equivalent of accept

Varol Okan varokan at movingsatellites.com
Wed Apr 21 13:53:35 CEST 2010

Martin Sustrik wrote:
> Hi Varol,
>> I am really sorry to throw that many questions at you. I am just
>> trying to understand and I am thankful for your help.
>> I have a server which is idly waiting for a client to connect. At
>> this point I have only one thread.
>> Once I get a client connection, I want to handle the the traffic in a
>> new thread.
>> I read in the zmq doc, that the socket will only handle send/recv
>> from within the same thread it was created, so I can't just pass the
>> context to the newly created client handler thread.
>> A second client gets a second thread etc. this is how the current
>> application works. I would like to use zmq for this, hence all my
>> questions :)
>> Can you guide me to documentation which describes a server
>> implementation with multiple worker threads and multiple sockets
>> using zmq ? Or tell me how you would use zmq to handle multiple
>> client connections through multiple threads
>> I think I read the whole documentation and example codes to no avail,
>> so I really appreciate your help.
> As far as I understand, what you want is a multi-threaded server. In 
> other words you have a server application which listens on a port. 
> Client connect to it and send their requests. Server dispatches these 
> requests to worker theads that process them and send the replies back to 
> the original clients.
> Is that right?
That is correct, only I would not have a predefined number of threads
but the # of threads depend on the connected clients.

This approach is used to store ( amongst other states ) login
information about the connected clients and do the processing according
to user restrictions. So if one user is 'root' and another is 'guest'
they'll be allowed to do different things.

I spent yesterday mostly reading up on the mailing list and it seems a
general pattern emerged with XREQ/XREP main socket and inproc sockets
for the worker threads.

So I have two questions:
1) Is there a simple, working example for this ( BTW. I love the
examples on the web page, small and concise )
2) Is there a example where each thread is using its own socket to
connect to the client

If these examples are missing I could work something up and it could be
added to the examples, as that issue seems to be coming up frequently.
Though with your comment of XREP/XREQ not being functional maybe I'll
use a standard REP/REQ socket instead ( BTW, whats the difference ? )

Please advice

Varol :)

> Martin
> _______________________________________________
> 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/20100421/8789e0f7/attachment.htm>

More information about the zeromq-dev mailing list