阻止的recv从另一个线程关闭套接字时不退出? [英] Blocking recv doesn't exit when closing socket from another thread?

查看:554
本文介绍了阻止的recv从另一个线程关闭套接字时不退出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux中,如果我们所说的阻止的recv 从一个线程并关闭从另一个线程在同一插座,的recv 不退出。

In Linux if we call blocking recv from one thread and close for the same socket from another thread, recv doesn't exit.

为什么?

推荐答案

检查套接字的所有文件描述符已经关闭。如果有任何停留在远端开放(假设这是您试图关闭的),在同行中一直没有执行有序关闭

Check that all file descriptors for the socket have been closed. If any remain open at the "remote end" (assuming this is the one you attempt to close), the "peer has not performed an orderly shutdown".

如果这仍然不能正常工作,请致电 关机(袜子,SHUT_RDWR) 对端,这将关闭插座,无论引用计数。

If this still doesn't work, call shutdown(sock, SHUT_RDWR) on the remote end, this will shut the socket down regardless of reference counts.

这篇关于阻止的recv从另一个线程关闭套接字时不退出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆