Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Asio, 0MQ, and Windows
From: Damien Kick (dkick_at_[hidden])
Date: 2013-08-13 16:33:55


Mathias Gaunard <mathias.gaunard <at> ens-lyon.org> writes:

>
> On 12/08/13 20:50, Damien Kick wrote:
>
> > And so, unless I'm once again missing something obvious (like casting
> > a SOCKET into a HANDLE)
>
> IIRC, with WINSOCK2, a SOCKET *is* a HANDLE.

Well, somebody forgot to tell 'boost::asio::windows::steam_handle' ;-)

But, I'm very excited because I think I found a way to accomplish on
Windows what I'd managed to get to work for me on POSIX, more or less.
This at least compiles and if I'm correctly understanding the
documentation for these functions that I've found online, then this
might even do the Right Thing (TM) at runtime. Thanks in advance if
anyone can help review this; i.e. somebody is already familiar with
these Windows functions.

   zmq::context_t zenv(1);
   zmq::socket_t zocket(zenv, ZMQ_PUSH);
   SOCKET zfd;
   std::size_t zfd_size = sizeof(zfd);
   zocket.getsockopt(ZMQ_FD, &zfd, &zfd_size);
   auto event_handle = CreateEvent(
       nullptr, // default security settings
       false, // automatic reset
       false, // initial state is unsignalled
       nullptr); // anonymous object
   assert(event_handle != nullptr);
   auto err = WSAEventSelect(zfd, event_handle, FD_READ);
   assert(!err);
   boost::asio::io_service ios;
   boost::asio::windows::object_handle io(ios, event_handle);
   io.async_wait(
       [](const boost::system::error_code& err) { });


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net