0
I am setting up a socket server in php, a simple chat. When I send a message or close a page, the following error appears: "Warning: socket_recv() Unable to read from socket[10053] An established connection was cancelled by the software on the host computer" and on the other line the same message, only with socket_write(), this only happens when I put socket_write to send messages to all clients, see a snippet of code:
foreach($read as $read_socket){
$bytes = socket_recv($read_socket, $data, 1024, null);
if($bytes === 0){
$key = array_search($read_socket, $array_clients);
unset($array_clients[$key]);
echo PHP_EOL . "Cliente desconectado...";
}else{
foreach($array_clients as $clients)
socket_write($clients, $data, strlen($data));
}
}
This is very strange because I have already disabled the firewall and Avast and the error continues. Whenever a client disconnects and socket_write() is not present, the "Client disconnected..." message usually appears, only if I echo $data inside Else to show messages from other clients, it appears " Ú" and then the message that the client was disconnected. Could you help me?