我引用了以下网页:
https://serverfault.com/questions/153983/sockets-found-by-lsof-but-not-by-netstat
使用Python,我在SSL套接字上遇到了同样的问题:
当我使用 socket.close()
时,套接字无限期地保持在 CLOSE_WAIT 状态
当我使用 socket.shutdown()
时,lsof 说“无法识别协议(protocol)”
解决方案是在关闭之前解开 SSL 层:
origsock = socket.unwrap()
origsock.close()
这会在我的应用程序中正确关闭套接字。
我想问一下 unwrap()
在 python 中做了什么以及如何在 c 中做到这一点?!
最佳答案
unwrap
执行正确的 SSL 关闭。这种关闭类似于 TCP 连接结束时的 FIN 握手,只是在 SSL/TLS 层。如何在 C 中完成此关闭取决于您正在使用的特定 SSL/TLS 堆栈。但对于 OpenSSL,您需要使用的函数是 SSL_shutdown .
关于python - 如何在c中实现Python socket.unwrap()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46780638/