[zeromq-dev] zmq_poll when socket is closed

KIU Shueng Chuan nixchuan at gmail.com
Tue Oct 13 23:23:57 CEST 2015


I didn't run your example but isn't the zmq_poll() call going to return
immediately before the 5 seconds are up?

POLLOUT indicates writability which is true for zmq sockets until the hwm
is reached.
On 13 Oct 2015 23:50, "Auer, Jens" <jens.auer at cgi.com> wrote:

> Hi,
>
> what is the semantics of zmq_poll when the remote side of the socket is
> closed? My sample program
> int main()
> {
>     zmq::context_t ctx;
>     zmq::socket_t s1{ctx, ZMQ_PAIR};
>     zmq::socket_t s2{ctx, ZMQ_PAIR};
>
>     s1.bind("inproc://1");
>     s2.connect("inproc://1");
>
>     auto t = std::thread( [&]() {
>         std::this_thread::sleep_for( std::chrono::seconds(5) );
>         s1.close();
>     });
>
>     zmq::pollitem_t pollitems[] = { {static_cast<void*>(s2), -1,
> ZMQ_POLLIN + ZMQ_POLLERR + ZMQ_POLLOUT, 0} };
>
>     auto rc = zmq::poll(pollitems, 1);
>
>     std::cout << rc << std::endl;
>     std::cout << pollitems[0].revents;
>
>     t.join();
>
>     return 0;
> }
>
> prints 2 which is ZMQ_POLLOUT. However, I cannot see this in the
> documentation.
>
> Best wishes,
>   Jens
>
> --
> *Jens Auer *| CGI | Software-Engineer
> CGI (Germany) GmbH & Co. KG
> Rheinstraße 95 | 64295 Darmstadt | Germany
> T: +49 6151 36860 154
> *jens.auer at cgi.com* <jens.auer at cgi.com>
> Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter
> *de.cgi.com/pflichtangaben* <http://de.cgi.com/pflichtangaben>.
>
> CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to
> CGI Group Inc. and its affiliates may be contained in this message. If you
> are not a recipient indicated or intended in this message (or responsible
> for delivery of this message to such person), or you think for any reason
> that this message may have been addressed to you in error, you may not use
> or copy or deliver this message to anyone else. In such case, you should
> destroy this message and are asked to notify the sender by reply e-mail.
>
> _______________________________________________
> 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/20151014/fbcf5895/attachment.htm>


More information about the zeromq-dev mailing list