I'm building 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 has been aborted by the software on the host computer " and in the other line with the same message, only with socket_write (), this only happens when I put socket_write to send the 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));
}
}
ThisisverystrangesinceIhavealreadydisabledthefirewallandavastandtheerrorcontinues.Wheneveraclientdisconnectsandsocket_write()isnotpresent,themessage"Client disconnected ..." appears normally, but in case of an echo $ data inside the else to show messages from other clients, "♥ Ú" and then the message saying that the client was disconnected. Could you help me?