从Boost.Asio的套接字类拆本地插座 [英] Detaching a native socket from Boost.ASIO's socket class
问题描述
是否有可能拆离Boost.Asio的套接字类本地插座?如果是这样,怎么能做到呢?我似乎无法找到任何文档中显而易见的。
Is it possible to detach a native socket from Boost.ASIO's socket class? If so, how can it be done? I can't seem to find anything obvious in the documentation.
由于什么,我试图完成的快速概览:我有一个类,使一个连接,并通过做一些Boost.Asio的谈判,然后传回上失败是成功还是0本机Windows SOCKET
As a quick overview of what I'm trying to accomplish: I have a class that makes a connection and does some negotiation using Boost.ASIO, then passes back a native Windows SOCKET on success or 0 on failure.
除非我弄错了,本机接口将被关闭,当我的boost :: ASIO :: basic_socket遭到破坏释放。
Unless I'm mistaken, the native socket will be closed and deallocated when my boost::asio::basic_socket is destructed.
推荐答案
回答我的问题。
Windows有一个WSADuplicateSocket功能,它可以用来复制本机插口。直到此套接字的所有描述符被释放底层套接字将继续开放。
Windows has a WSADuplicateSocket function, which can be used to duplicate the native socket. The underlying socket will remain open until all descriptors for this socket are deallocated.
http://msdn.microsoft.com/en -us /库/ ms741565(VS.85)的.aspx
这篇关于从Boost.Asio的套接字类拆本地插座的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!