本文介绍了如何把C ++ / CLI的.Net插座到升压:: ASIO插座?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要的很简单 - code,从C ++ / CLI净插槽创造新的升压ASIO插座样品。如何创建这样的事?
下面是什么,我想这样做伪code:
.NET ::插座;
提高:: ASIO ::插座B:
b.assign(a.nativeWin32Socket());
解决方案
您是否尝试过?
b.assign(a.Handle.ToInt32());
另外请注意,他们将需要使用WSADuplicateSocket,你可能会得到这两个B和A将关闭套接字,并指出你没有想到的。
所以,你需要的东西,如:
SOCKET原生= WSADuplicateSocket(a.Handle.ToInt32(),...);
b.assign(原生);
完整的答案(测试)
SOCKET原生= A-> Handle.ToInt32();
//现在本机是一个真正的插座
b.assign(升压:: ASIO ::知识产权:: TCP :: V4(),原生);
现在是用WSADuplicateSocket复制套接字好主意:
What I want is simple - code sample of creating new boost asio socket from C++/CLI .Net socket. How to create such thing?
Here is pseudo code of what I would like to do:
.net::socket a;
boost::asio::socket b;
b.assign(a.nativeWin32Socket());
解决方案
Have you tried?
b.assign(a.Handle.ToInt32());
Also note they you will need to use WSADuplicateSocket as you may get that both b and a will close the socket and point you don't expect.
So you need something like:
SOCKET native = WSADuplicateSocket(a.Handle.ToInt32(),...);
b.assign(native);
Full Answer (Tested)
SOCKET native = a->Handle.ToInt32();
// Now native is a real socket
b.assign(boost::asio::ip::tcp::v4(), native);
Now it is good idea to duplicate the socket using WSADuplicateSocket:
这篇关于如何把C ++ / CLI的.Net插座到升压:: ASIO插座?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!