应用程序是否应该在套接字描述符的 close()
之前使用 FD_CLR()
?
关闭是否会处理FD_CLR()
?有时我观察到,即使没有 FD_CLR()
,close()
也能工作,但有时套接字仍然显示在 netstat 条目中。
为什么这个不稳定?
最佳答案
Should applications use FD_CLR() before close() of a socket descriptor?
如果您要在关闭套接字后继续使用 fd_set
,那么您当然应该使用 FD_CLR
。
Does shutdown take care of FD_CLR()?
没有。
Sometimes I observe that close() works even without FD_CLR() but sometimes the socket still shows up in the netstat entries.
如何显示?而且 FD_CLR
与保持在 TIME-WAIT
或 netstat
中的其他状态的端口没有任何关系。
您似乎同时问了三个问题。
关于c++ - 关闭没有 FD_CLR 的套接字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27141463/