On 08/09/2013 08:34 PM, Damien Kick wrote:
The reason why there is a assign, but no release-function for
boost::asio::ip::tcp::sockets is that once a socket is "bound" to a
completion port you cannot "unbound" it or "bound" it to another
completion-port.
I nearly forgot this one. You have to make sure that the Boost.Asio
socket does not close the underlying socket. Here is an explanation
of how it can be done:
http://lists.zeromq.org/pipermail/zeromq-dev/2011-May/011666.html
Oh, very good. Thanks for the tip. I'd been achieving the same thing by ensuring that
stream_descriptor::release was getting called but I like this approach better.
I used to use this technique in an Asio wrapper for ZeroMQ and it works
just fine.
Yeah, so far I've been having very good luck with Asio and 0MQ on POSIX. But I'm still stuck on Windows :( The code that I was able to get to compile is not happy at runtime.
int main()
{
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);
boost::asio::windows::stream_handle::native_handle_type
zfd_native(&zfd);
boost::asio::io_service ios;
boost::asio::windows::stream_handle io(ios, zfd_native);
}
Stepping line-by-line in the debugger for Visual Studio 2010, when I get to the line attempting to create the windows::stream_handle, I get
Unhandled exception at 0x77b815de in test-zee-zmq-socket.exe: Microsoft C++ exception: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> > at memory location 0x00c1fc7c..
And so there obviously must be more to creating a windows::stream_handle than this but I'm still quite in the dark as to what that might be. The stack trace I'm getting doesn't help me much, either, but I am also am quite ignorant about most things Windows.
ntdll.dll!77b815de()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!77b815de()
ntdll.dll!77b7014e()
KernelBase.dll!7608c41f()
> msvcr100d.dll!_nh_malloc_dbg_impl(unsigned int nSize=8, int nhFlag=0, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0, int * errno_tmp=0x00c1fb0c) Line 239 + 0x19 bytes
C++
msvcr100d.dll!_nh_malloc_dbg(unsigned int nSize=8, int nhFlag=0, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0) Line 302 + 0x1d bytes
C++
msvcr100d.dll!malloc(unsigned int nSize=12712804) Line 56 + 0x15 bytes
C++
00c1fb64()
00cc8220()
However, I got dissatisfied by how ZeroMQ hides too much detail from me
(like disconnect, so I cannot do things like Wake-on-LAN.)
Yeah, I'd been thinking something similar, i.e. wanting to be able to know more about dis/connect, but then I discovered
zmq_socket_monitor <
http://api.zeromq.org/3-2:zmq-socket-monitor>. Maybe this was added since last you looked at it(0MQ)?