array (), "Contexts" => array (), ); function getContextSockets () { global $socketContext; return $socketContext ["Sockets"]; } function setContextSocket ($Socket, $Context) { global $socketContext; // Append to sockets $socketContext ["Sockets"][] = $Socket; // Find key of socket $Candidates = array_keys ($socketContext ["Sockets"], $Socket, true); foreach ($Candidates as $Candidate) $socketContext ["Contexts"][$Candidate] = $Context; return true; } function getSocketContext ($Socket) { global $socketContext; // Find key of socket $Candidates = array_keys ($socketContext ["Sockets"], $Socket, true); // Find the context foreach ($Candidates as $Candidate) if (isset ($socketContext ["Contexts"][$Candidate])) return $socketContext ["Contexts"][$Candidate]; return null; } function unsetSocketContext ($Socket) { global $socketContext; // Find key of socket $Candidates = array_keys ($socketContext ["Sockets"], $Socket, true); // Find the context foreach ($Candidates as $Candidate) { unset ($socketContext ["Sockets"][$Candidate]); unset ($socketContext ["Contexts"][$Candidate]); } } ?>