退出阻塞选择调用

发布于 2024-08-29 00:36:50 字数 135 浏览 3 评论 0原文

我正在调用一个第三方 API,它创建一个套接字,进行连接,然后通过将套接字传递给永远阻塞来调用 select API。

我无权访问套接字。有什么方法可以让我的应用程序进行选择调用而无需访问套接字?

我的平台是Windows。

I am calling a third party API which creates a socket, does a connect and then calls select API by passing the socket to block forever.

I don't have access to the socket. Is there some way in which I can make the select call come out from my application without having access to the socket?

My platform is Windows.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

粉红×色少女 2024-09-05 00:36:50

除非您可以访问所使用的套接字或选择集,否则通常无法执行此操作。

如果您可以访问套接字,请通过 closesocket() 将其关闭。
如果您可以访问读取集,请在那里填充一个虚拟套接字,然后参见上一点。

如果这些都不起作用,您可以:

  • 确保这发生在一个单独的线程中,您可以稍后杀死该线程(尽管这会造成一些相当明显的资源泄漏)
  • 尝试使用 弯路(不推荐)
  • 承认失败。

You can't normally do this unless you can access either the socket or the select set used.

If you can get access to the socket, close it via closesocket().
If you can get access to the read set, stuff a dummy socket there, then see previous point.

If none of these work you can either:

  • Ensure this happens in a separate thread, which you can later kill (although this will create some fairly obvious resource leaks)
  • Attempt to override select using something like Detours (not recommended)
  • Admit defeat.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文