$server_socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_bind($server_socket, '127.0.0.1', 9000); socket_listen($server_socket); $clients = [$server_socket]; while (true) { $read = $clients; if (socket_select($read, $write, $exception, 0) < 1) { continue; } if (in_array($server_socket, $read)) { $new_socket = socket_accept($server_socket); $clients[] = $new_socket; $key = array_search($server_socket, $read); unset($read[$key]); } foreach ($read as $client) { $data = socket_read($client, 1024); if (!$data) { $key = array_search($client, $clients); unset($clients[$key]); socket_close($client); } else { echo "Received data: $data\n"; socket_write($client, "Response: $data"); } } }In this example, we create a server socket and listen on port 9000. We then initialize an array of clients with just the server socket. Inside the while loop, we use the Event select function to wait for incoming data on any of the sockets in the $clients array. If the server socket is in the $read array, it means we have a new client connection. We accept the connection and add the new socket to the $clients array. If any other client socket is in the $read array, it means we have incoming data to read. We read the data, and if there is no more data, it means the client has disconnected. We remove the client socket from the $clients array and close the socket. If there is more data, we send a response back to the client. The package library for the Event select in PHP is the libevent library.