Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有个问题。我在 linux 中运行 TCP 服务器。我通过 close(socket) 调用关闭套接字。但是当我再次尝试重新绑定时,绑定调用失败,错误号 98 => 端口已绑定。我应该如何解除绑定该套接字?
您必须在套接字上设置 SO_REUSEADDR 选项,请参见此处。
您可以尝试设置SO_REUSEADDR套接字选项,请参阅此问题进行一些讨论。
SO_REUSEADDR