Hallo, I am trying to integrate proton messenger with a regular select-based event loop. Regrettably there's not much documentation about reading and sendingn messages in passive mode using selectors. Can you give a quick look to the pseudo-code, describing message input in my event loop and verify whether I understand it correctly?
Here goes the pseudo-code: for (;;) { foreach messenger: messenger::recv(N); // Make sure message read automata is started. foreach selectable in messenger: if (is_registered(selectable)) continue; // Selectable is already in use by event loop // Create an I/O object which refers to selectable // and add it to the I/O list iolist << new IO(selectable) foreach iolist item: if is_terminal(item): Remove item from iolist pn_selectable_free(item::selectable) continue; if is_readable: add selection fd to read mask if is_writable: add selection fd to write mask if (selection has deadline) schedule timer for this iolist item select(read_mask, write_mask, timeout) foreach iolist item: if (read event signalled) pn_selectable_readable(item::selection) if (write event signalled) pn_selectable_writable(item::selection) If we had any read events check whether some messages were placed into input queue. If no messages are available pn_messenger_get() will not block, but rather will return PN_EOS foreach messenger: while pn_messenger_get(messenger, message) != PN_EOS Handle input message Check whether some timers have expired. If expired timer refers to the proton I/O object, delete this object (this will also exclude it from iolist and select masks) } All messengers are created in non-blocking and passive mode. Some of the messengers are already subscribed to queues. To send messages I just use pn_messenger_put as usual and pn_selectable_writable takes care about actual message delivery. Best regards, -- \ / | | (OvO) | Mikhail Iwanow | (^^^) | Voice: +7 (911) 223-1300 | \^/ | E-mail: iv...@logit-ag.de | ^ ^ | | --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@qpid.apache.org For additional commands, e-mail: users-h...@qpid.apache.org