if(!posix_setsid()) { $DAEMON->trace('Could not detach daemon process from terminal!'); } } else { // Cannot go demonic $DAEMON->trace('Unholy spirit possession failed: PHP is not compiled with --enable-pcntl'); } */ $DAEMON->trace('Started Moodle chatd on port ' . $CFG->chat_serverport . ', listening socket ' . $DAEMON->listen_socket, E_USER_WARNING); /// Clear the decks of old stuff $DB->delete_records('chat_users', array('version' => 'sockets')); while (true) { $active = array(); // First of all, let's see if any of our UFOs has identified itself if ($DAEMON->conn_activity_ufo($active)) { foreach ($active as $handle) { $read_socket = array($handle); $write = null; $except = null; $changed = socket_select($read_socket, $write, $except, 0, 0); if ($changed > 0) { // Let's see what it has to say $data = socket_read($handle, 2048); // should be more than 512 to prevent empty pages and repeated messages!! if (empty($data)) { continue; } if (strlen($data) == 2048) { // socket_read has more data, ignore all data $DAEMON->trace('UFO with ' . $handle . ': Data too long; connection closed', E_USER_WARNING);
echo " chatd.php --start -l\n\n"; die; } if (!function_exists('socket_set_option')) { echo "Error: Function socket_set_option() does not exist.\n"; echo "Possibly PHP has not been compiled with --enable-sockets.\n\n"; die; } $daemon->init_sockets(); $daemon->trace('Started Moodle chatd on port ' . $CFG->chat_serverport . ', listening socket ' . $daemon->listen_socket, E_USER_WARNING); // Clear the decks of old stuff. $DB->delete_records('chat_users', array('version' => 'sockets')); while (true) { $active = array(); // First of all, let's see if any of our UFOs have identified itself. if ($daemon->conn_activity_ufo($active)) { foreach ($active as $handle) { $readsocket = array($handle); $write = null; $except = null; $changed = socket_select($readsocket, $write, $except, 0, 0); if ($changed > 0) { // Let's see what it has to say. $data = socket_read($handle, 2048); // Should be more than 512 to prevent empty pages and repeated messages! if (empty($data)) { continue; } if (strlen($data) == 2048) { // If socket_read has more data, ignore all data. $daemon->trace('UFO with ' . $handle . ': Data too long; connection closed', E_USER_WARNING);