[zeromq-dev] CZMQ and Server and Client Sockets

Pieter Hintjens ph at imatix.com
Mon Aug 17 12:36:51 CEST 2015


+1 for this and for using "routing id" instead of "identity"... it's a
change I'd like to make everywhere, deprecating the old (misleading)
name.

On Mon, Aug 17, 2015 at 11:04 AM, Doron Somech <somdoron at gmail.com> wrote:
> No problem, I also agree as I think we need minimal change.
>
> I made the change:
> https://github.com/somdoron/libzmq/commit/5bae6911afba90de42b9fd21315f6d702e1bb2c6
>
> I will wait with the PR until other will weigh in.
>
> Also I think the poller name is not great, I prefer another but didn't come
> up with a good one, few alternatives:
> * signaler - it is the internal name in libzmq
> * efd - for event fd
> * polling_fd
> * poll_fd
> * pollfd
>
> What do you think?
>
>
>
>
>
> On Mon, Aug 17, 2015 at 10:29 AM, KIU Shueng Chuan <nixchuan at gmail.com>
> wrote:
>>
>> The structure of zmq_pollitem_t is part of the public api and abi. All
>> existing programs would require a recompile.
>>
>> Perhaps others would like to weigh in on this?
>>
>> On 17 Aug 2015 14:17, "Doron Somech" <somdoron at gmail.com> wrote:
>>>
>>> A little nasty but will work, I already have the zmq_poller_get_fd method
>>> (right now it is not public).
>>> I will make the change.
>>>
>>> What disadvantage do you see to the change of the structure?
>>>
>>> On Mon, Aug 17, 2015 at 6:11 AM, KIU Shueng Chuan <nixchuan at gmail.com>
>>> wrote:
>>>>
>>>> Do you think it would be worthwhile to preserve ABI compatibility of the
>>>> zmq_pollitem_t structure?
>>>>
>>>> Perhaps for threadsafe sockets, the user could extract the fd of the
>>>> poller object and populate the pollitem fd field himself?
>>>>
>>>> e.g.
>>>> socket!=NULL && fd!=0 ==> threadsafe zmq socket
>>>> socket!=NULL && fd==0 ==> regular zmq socket
>>>> socket==NULL ==> regular TCP socket (or any fd on unix)
>>>>
>>>>
>>>> On Sun, Aug 16, 2015 at 11:06 PM, Doron Somech <somdoron at gmail.com>
>>>> wrote:
>>>>>
>>>>> so, I made a pull request to fix the issue, moving field to the end of
>>>>> struct:
>>>>>
>>>>> https://github.com/zeromq/libzmq/pull/1526
>>>>>
>>>>> On Sun, Aug 16, 2015 at 5:54 PM, Doron Somech <somdoron at gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> I will try to fix that...
>>>>>>
>>>>>> On Sun, Aug 16, 2015 at 5:43 PM, KIU Shueng Chuan <nixchuan at gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> Hello, the new definition for zmq_pollitem_t would break code like
>>>>>>> the following:
>>>>>>>
>>>>>>> zmq_pollitem_t pollitems [] = {
>>>>>>>             { zsock, 0, ZMQ_POLLIN, 0 },
>>>>>>>             { NULL, fd, ZMQ_POLLIN, 0 }
>>>>>>>         };
>>>>>>>
>>>>>>> On 16 Aug 2015 19:10, "Doron Somech" <somdoron at gmail.com> wrote:
>>>>>>>>
>>>>>>>> So I made a pull request which add polling on multiple sockets:
>>>>>>>>
>>>>>>>> https://github.com/zeromq/libzmq/pull/1525
>>>>>>>>
>>>>>>>> Polling on thread safe sockets is a little different then regular
>>>>>>>> socket, take a look at the gist:
>>>>>>>>
>>>>>>>> https://gist.github.com/somdoron/902169bf115d3534bd24
>>>>>>>>
>>>>>>>> Next is making a pull request to CZMQ to use the new ability.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Sun, Aug 16, 2015 at 12:53 AM, Brian Knox
>>>>>>>> <bknox at digitalocean.com> wrote:
>>>>>>>>>
>>>>>>>>> Makes sense to me!  The API is close enough to the other poller
>>>>>>>>> implementations that there's no surprises.
>>>>>>>>>
>>>>>>>>> Cheers!
>>>>>>>>> Brian
>>>>>>>>>
>>>>>>>>> On Sat, Aug 15, 2015 at 5:21 PM, Doron Somech <somdoron at gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> Polling on multiple thread safe socket is a little bit different,
>>>>>>>>>> because thread safe doesn't have a FD, so we need to create one for all
>>>>>>>>>> thread safe sockets for each thread before calling the zmq_poll.
>>>>>>>>>>
>>>>>>>>>> So I want to make it very close to the current API, this what I
>>>>>>>>>> have so far:
>>>>>>>>>>
>>>>>>>>>> https://gist.github.com/somdoron/902169bf115d3534bd24
>>>>>>>>>>
>>>>>>>>>> zmq_poller_t is actually a FD, when added to the thread safe
>>>>>>>>>> socket the socket will signal it once a command is ready, multiple sockets
>>>>>>>>>> can use the same poller. When signalled the zmq_poll will check all sockets
>>>>>>>>>> for events.
>>>>>>>>>>
>>>>>>>>>> What do you think?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Sat, Aug 15, 2015 at 5:54 PM, Brian Knox
>>>>>>>>>> <bknox at digitalocean.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>> Doron - as a heads up, being able to poll multiple sockets from
>>>>>>>>>>> zpoller would be of great interest to me (I use zpoller in goczmq quite a
>>>>>>>>>>> bit).
>>>>>>>>>>>
>>>>>>>>>>> Cheers,
>>>>>>>>>>> Brian
>>>>>>>>>>>
>>>>>>>>>>> On Sat, Aug 15, 2015 at 3:48 AM, Doron Somech
>>>>>>>>>>> <somdoron at gmail.com> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Andrew are you using CZMQ? which class do you use for multiple
>>>>>>>>>>>> polling, zloop or zpoller?
>>>>>>>>>>>>
>>>>>>>>>>>> On Fri, Aug 14, 2015 at 10:36 PM, Andrew Simpson
>>>>>>>>>>>> <simpsonar77 at yahoo.com> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>> this sounds really excellent!  I am building an application
>>>>>>>>>>>>> that would greatly benefit from this over a standard Router/Dealer setup.
>>>>>>>>>>>>> The only thing that will hold me back right now is the lack of polling on
>>>>>>>>>>>>> multiple client/server sockets.  I definitely need that.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Good stuff!
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Friday, August 14, 2015 9:09 AM, Doron Somech
>>>>>>>>>>>>> <somdoron at gmail.com> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Hi All,
>>>>>>>>>>>>>
>>>>>>>>>>>>> I added server and client sockets support to CZMQ, you can take
>>>>>>>>>>>>> a look at the change at the following pull request:
>>>>>>>>>>>>>
>>>>>>>>>>>>> https://github.com/zeromq/czmq/pull/1059
>>>>>>>>>>>>>
>>>>>>>>>>>>> Server socket is like router socket except you don't have an
>>>>>>>>>>>>> identity frame, each message also include routing id which is an int (vs
>>>>>>>>>>>>> byte array). So each message coming from a server socket include a routing
>>>>>>>>>>>>> id which can be retrieve by calling zframe_routing_id. When sending a
>>>>>>>>>>>>> message you must set the routing id by calling zframe_set_routing_id. You
>>>>>>>>>>>>> can use zframe_send_reply with both the destination frame and the source
>>>>>>>>>>>>> frame (which include the routing id), the method copy the routing id from
>>>>>>>>>>>>> the source frame to the destination frame and then send the message.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Client socket is same as dealer socket. Client and Server can
>>>>>>>>>>>>> only talk to each other.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Following is a small example on how to use the new client and
>>>>>>>>>>>>> server sockets:
>>>>>>>>>>>>> https://gist.github.com/somdoron/542b74922f652d229566
>>>>>>>>>>>>>
>>>>>>>>>>>>> Client and server socket are thread safe (currently only
>>>>>>>>>>>>> support single frame messages but that might change, I think) so if your
>>>>>>>>>>>>> protocol is single frame you can use the server and client sockets from
>>>>>>>>>>>>> multiple threads.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Polling on multiple client or server sockets is not supported
>>>>>>>>>>>>> yet.
>>>>>>>>>>>>>
>>>>>>>>>>>>> In the coming week I plan to also add zproto support and
>>>>>>>>>>>>> complete the polling on multiple sockets.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Doron
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>>> zeromq-dev mailing list
>>>>>>>>>>>>> zeromq-dev at lists.zeromq.org
>>>>>>>>>>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>>> zeromq-dev mailing list
>>>>>>>>>>>>> zeromq-dev at lists.zeromq.org
>>>>>>>>>>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>> zeromq-dev mailing list
>>>>>>>>>>>> zeromq-dev at lists.zeromq.org
>>>>>>>>>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> zeromq-dev mailing list
>>>>>>>>>>> zeromq-dev at lists.zeromq.org
>>>>>>>>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> zeromq-dev mailing list
>>>>>>>>>> zeromq-dev at lists.zeromq.org
>>>>>>>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> zeromq-dev mailing list
>>>>>>>>> zeromq-dev at lists.zeromq.org
>>>>>>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> zeromq-dev mailing list
>>>>>>>> zeromq-dev at lists.zeromq.org
>>>>>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> zeromq-dev mailing list
>>>>>>> zeromq-dev at lists.zeromq.org
>>>>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> zeromq-dev mailing list
>>>>> zeromq-dev at lists.zeromq.org
>>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> zeromq-dev mailing list
>>>> zeromq-dev at lists.zeromq.org
>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>>
>>>
>>>
>>> _______________________________________________
>>> zeromq-dev mailing list
>>> zeromq-dev at lists.zeromq.org
>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>
>>
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>
>
> _______________________________________________
> 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