草庐IT

allSockets

全部标签

php - 确定客户端是否已使用套接字关闭与服务器的连接

我正在尝试检查客户端是否已断开连接,以便我可以关闭客户端连接以允许客户端重新连接。我有以下内容。$socket=@socket_create_listen("12345");while(true){$client=socket_accept($socket);socket_write($client,'hello');while(true){//Codetoexitthisloopwhenclientloosesconnectionsocket_write($client,'');echosocket_last_error($socket);}socket_close($client)