I am looking at the bstar server implementation using the C czmq code and I see
something that is unclear to me. When a new voter is added, the voter does the
following:
void *socket = zsocket_new (ctx, type);
..
zmq_pollitem_t poller = { socket, 0, ZMQ_POLLIN };
return zloop_poller (loop, &poller, s_voter_ready, this);
Essentially we are creating a zsocket and stuffing it ino the poll item
structure which eventually finds its way into the poller list of the reactor.
int
zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg)
{
..
s_poller_t *poller = s_poller_new (item, handler, arg);
..
if (poller) {
poller->list_handle = zlistx_add_end (self->pollers, poller);
..
Eventually at some later point, the reactor server starts and it builds a new
poll set:
static int
s_rebuild_pollset (zloop_t *self)
{
..
self->poll_size = zlistx_size (self->readers) + zlistx_size (self->pollers);
self->pollset = (zmq_pollitem_t *) zmalloc (self->poll_size * sizeof
(zmq_pollitem_t));
..
while (poller) {
self->pollset [item_nbr] = poller->item;
self->pollact [item_nbr] = *poller;
item_nbr++;
poller = (s_poller_t *) zlistx_next (self->pollers);
}
At this point the pollset has an zsocket item in it socket pointer. This is
eventually used in the reactor loop to poll for events.
int
zloop_start (zloop_t *self)
{
..
rc = zmq_poll (self->pollset, (int) self->poll_size, s_tickless (self));
But at this point my understanding is that zmq_poll should be expecting a 0MQ
socket created by zmq_socket. How is it then that zmq_poll is aware of the
zsocket object created in the higher level czmq library? I would have imagined
that s_rebuild_pollset would do some sort of translation to from zsocket to a
0MQ socket. Where is this happening?
What am I missing here?
Regards,
Sreekant
Sreekant Sreedharan
Senior Technical Consultant
Phone 0471-3048888 (Ext.269)
Alamy - http://www.alamy.com
Alamy Images India Pvt. Ltd.
C-16, Gayatri Building,
Technopark, Thiruvananthapuram
Kerala, India. PIN - 695 581
--------------------------------------------------------------------------------
A disclaimer applies to all emails sent from Alamy Limited.
For the full text please see http://www.alamy.com/terms/email-disclaimer.asp
--------------------------------------------------------------------------------
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev