TCP CLOSE_WAIT 连接状态 - 未知原因

问题描述:

为什么socket_shutdown($socket, 2); 有时虽然通过执行socket_close($socket); 在关闭后立即关闭了套接字,但仍使套接字处于CLOSE_WAIT 状态.代码> ?

Why does socket_shutdown($socket, 2); sometimes leave the socket in the CLOSE_WAIT state although the socket is closed right after the shutdown by doing socket_close($socket); ?

没有.CLOSE_WAIT 是由于在本地应用程序关闭此端之前收到来自对等端的传入关闭.当应用程序关闭此端时,状态转换.关机与此无关.

It doesn't. CLOSE_WAIT is caused by the receipt of an incoming close from the peer before the local application has closed this end. When the application closes this end, the state transitions. Shutdown has nothing to do with it.