本文介绍了c ++ linux accept()在套接字关闭后阻塞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个侦听新连接的线程

I have a thread that listens for new connections

 接受 c> 继续 ,那么你应该做的是向 accept 中阻塞的线程发送一个信号。这将给它EINTR它可以干净地脱开 - 然后然后关闭套接字。不要使用它以外的线程关闭它。

If you meant that a call which was previously made to accept continues blocking after close, then what you should do is send a signal to the thread which is blocked in accept. This will give it EINTR and it can cleanly disengage - and then close the socket. Don't close it from a thread other than the one using it.

这篇关于c ++ linux accept()在套接字关闭后阻塞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 20:33