using socket with the overlapped operation selected the event-based completion notification; Have 2 events, one for data, the other to cancel long send/recv:
HANDLE events[] = { m_hDataEvent, m_hInterruptEvent };
然后打电话给WSASend,
WSASend(m_Socket, &DataBuf, 1, NULL, 0, &SendOverlapped, NULL);
和继 继 继 继 继 继
WSAWaitForMultipleEvents(2, events, FALSE, INFINITE, FALSE);
which is setup to return on any one event signaled. Now assume send is in progress, and m_hInterruptEvent is signaled. WSAWaitForMultipleEvents returns, technically the function calling send can return as well and delete internally allocated buffers.
我不清楚的是,WSASend可能仍然在背景中运作,删除缓冲在最好的情况下会造成数据腐败。
< energ> 如果插座需要立即用于其它东西, 那么阻止背景发送/ 接收的正确方式是什么? energy>
I looked at the CanceleIO (), 但是 MSDN 从未提及它与索凯茨的关系, 它是否只与基于文件 IO 一起工作? em>