- 论坛徽章:
- 1
|
原帖由 freecr 于 2009-7-8 17:38 发表 ![]()
我写的服务器bind9919端口,写的客户端程序连接服务器。当客户端连上服务器后,如果服务器异常断开,比如CTRL+C退出后,用netsate看会有客户端到服务器的连接状态,这时候再重启服务器程序会提示bind failed ad ...
TIME_WAIT状态
UNP3
By default, when the listening server is restarted in (d) by calling socket, bind, and listen, the call to bind fails because the listening server is trying to bind a port that is part of an existing connection (the one being handled by the previously spawned child). But if the server sets the SO_REUSEADDR socket option between the calls to socket and bind, the latter function will succeed. All TCP servers should specify this socket option to allow the server to be restarted in this situation. |
|