[zeromq-dev] about using ZMQ_FD in an external select loop

diffuser78 diffuser78 at gmail.com
Fri Sep 7 01:49:52 CEST 2012


Thanks Justin.

But my question revolves around the external select() loop. I want to know
whether external select() loop  will wake the ZMQ FD time and again until
all the bytes are read. I looked at some part of the code in router.cpp and
it feels like that ZMQ reads partial messages so that the external select()
loop won't bother waking the ZMQ FD until new set of bytes are received.

My main concern is that in my app, I don't want the external select() loop
to wake ZMQ fd time and again because the bytes were not read previously.
It will skew the performance of other fds in the system.

I want some sort of confirmation from gurus here that indeed it is true.

Thanks.

On Thu, Sep 6, 2012 at 4:35 PM, Justin Karneges <justin at affinix.com> wrote:

> The ZMQ_FD is a special fd you use to get notified of events on a zmq
> socket.
> It is not the actual underlying network socket that receives messages.
> Remember a zmq socket is "virtual", and under the hood it may be managing
> many
> network sockets (or none at all, if you consider the ipc type).
>
> I don't believe ZMQ_FD will indicate readability if a partial message is
> received over the network. At least I don't see a reason why zmq would
> want to
> bother the app about this. That said, even if ZMQ_FD gets indicated as
> readable more often than necessary, you should simply get the resulting
> ZMQ_EVENTS and act on them.
>
> On Thursday, September 06, 2012 04:24:43 PM diffuser78 wrote:
> > I did not frame my question correctly and subject was misleading too. Let
> > me put that correctly.
> >
> > I am using a ZMQ FD in an external select() loop, i,.e, a ZMQ FD is added
> > to the set of fds (regular unix fds) in an external select() loop.
> >
> > Consider a situation, for a given message (in a router dealer pattern),
> > only a few bytes are received at the receiver end and not the complete
> > message, so the external select() loop would wake up the ZMQ FD since it
> > can read atleast few bytes, but when we call zmq_getsockopt() API with an
> > option of ZMQ_EVENTS to get the list of events on the socket, ZMQ doesn't
> > return any FD since no complete message is recvd (only a few bytes have
> > been recvd). My question is:
> >
> > During the next select() iteration, would external select() wake up ZMQ
> FD
> > again because we did not read the few bytes that were ready to be read on
> > that fd OR will it NOT wake up ZMQ FD until new bytes are available for
> > reading on this fd? What is ZMQ behavior in this case.
> >
> > Any help is greatly appreciated.
> >
> > Thanks.
> >
> > On Wed, Sep 5, 2012 at 5:41 PM, diffuser78 <diffuser78 at gmail.com> wrote:
> > > Hi,
> > >
> > > I am using a ZMQ FD in an external select() loop, that is, a ZMQ FD is
> > > added to the set of fds (regular unix fds) in an external select loop.
> > >
> > > Consider a situation, for a given message (in a router dealer pattern),
> > > only a few bytes are received at the receiver end and not the complete
> > > message, so the external select() loop would wake up the ZMQ FD since
> it
> > > can read atleast few bytes, but when we do a ZMQ_POLL, ZMQ  doesn't
> return
> > > any FD since no complete message is recvd (only a few bytes have been
> > > recvd). My question is:
> > >
> > > Next time, would external select() wake up ZMQ FD again because it is
> > > level triggered or does ZMQ internally reads those bytes so that
> external
> > > select loop won't wake up ZMQ FD until new set of bytes are received ?
> > >
> > > Please let me know your thoughts.
> > >
> > > DJ
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120906/0cfd7ea8/attachment.html>


More information about the zeromq-dev mailing list