早教吧 育儿知识 作业答案 考试题库 百科 知识分享

socket结束后如何立刻释放端口-socket的服务端和客户端分别是两个进程使用socketclose后,为何端口不能立即释放,需要等一分钟由系统自动释放.注:linux环境下.注意到手册上对socketclose函数有

题目详情
socket结束后如何立刻释放端口 -
socket的服务端和客户端分别是两个进程使用socket_close后,为何端口不能立即释放,需要等一分钟由系统自动释放.注:linux环境下.注意到手册上对socket_close函数有这样一条评论,With the BSD socket implementation (which is the socket interface used by PHP),a socket_close() may close the socket,but there may yet be data to send.Until the data is sent,the port will not be available.Therefore,all further bindings attempted on that port will not be acceptable due to the \'port can not be reused\' (the approximate message,anyway) error.Ordinarily,if the REUSABLE socket option is set,the only thing that will raise such an error is a binding to a specific IP/PORT combination that is already bound.……究竟该怎么办?
▼优质解答
答案和解析
自己解决了,绑定之前加一个,重用端口socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1)) 查看原帖>>