gpt4 book ai didi

c++ - 如何中断正在等待 recv 函数的线程?

转载 作者:可可西里 更新时间:2023-11-01 16:36:35 25 4
gpt4 key购买 nike

<分区>

我有一个卡在 recv 函数上的套接字监听器:

size_t recvLen = recv(sock, buf, 512, 0);

我想通过打断它来终止这个线程。 MSDN 说:

When issuing a blocking Winsock call such as recv, Winsock may need to wait for a network event before the call can complete. Winsock performs an alertable wait in this situation, which can be interrupted by an asynchronous procedure call (APC) scheduled on the same thread.

我该怎么做?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com