On Aug 11, 2013, at 4:32 PM, Damien Kick
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()
I've also tried 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::io_service ios; boost::asio::windows::stream_handle io(ios, GetStdHandle(zfd)); } Which also compiles but then I'm still getting the same exception at runtime. And so apparently a SOCKET is not the same as a HANDLE (?), even though http://msdn.microsoft.com/en-us/library/windows/desktop/ms741476(v=vs.85).as... tells me that The WPUCreateSocketHandle function creates a new socket handle. Syntax C++ SOCKET WPUCreateSocketHandle( _In_ DWORD dwCatalogEntryId, _In_ DWORD_PTR dwContext, _Out_ LPINT lpErrno ); <sigh/> It's so annoying because I have this feeling that there is probably just one stupid little conversion function that I need to be calling but it continues to elude me :( ________________________________ This e-mail and any attachments are confidential. If it is not intended for you, please notify the sender, and please erase and ignore the contents.
Damien Kick
<sigh/> It's so annoying because I have this feeling that there is probably just one stupid little conversion function that I need to be calling but it continues to elude me :(
And ... that missing conversion function was simply a mother father Chinese dentist cast. <sigh/> I had managed to get lost in the swirl of GetStdHandle, DuplicateHandle, WSADuplicateSocket, and the odd _open_osfhandle ... But then, after all of that fuss, I find that: 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); HANDLE handle = (HANDLE)zfd; boost::asio::io_service ios; boost::asio::windows::stream_handle io(ios, handle); io.async_read_some( boost::asio::null_buffers(), [](const boost::system::error_code& err, std::size_t) { }); Does not compile: 2>.../stream_handle_service.hpp(195): error C2248: \ 'boost::asio::detail::win_iocp_handle_service::async_read_some' : \ cannot access private member declared in class \ 'boost::asio::detail::win_iocp_handle_service' Sure enough, I find ... class win_iocp_handle_service { private: // Prevent the use of the null_buffers type with this service. // [... snip ...] template <typename Handler> void async_read_some(implementation_type& impl, const null_buffers& buffers, Handler& handler); // [... snip ...] }; And so, unless I'm once again missing something obvious (like casting a SOCKET into a HANDLE), it doesn't seem that the approach of using the ZMQ_FD and boost::asio::null_buffers is going to work for me on both POSIX and Windows.
Mathias Gaunard
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) { });
participants (2)
-
Damien Kick
-
Mathias Gaunard