function send($msg, $type = '')
    {
        // Set a short timeout to prevent long hangs
        stream_set_timeout($this->handle, 2);
        // Send message over connection
        fwrite($this->handle, $msg);

        // Check what type is required
        if ($type == 'array') {
            // If array loop and create array
            $response = array();
            $line_num = 0;
            while (!feof($this->handle)) {
                if (($response[$line_num] = fgets($this->handle, 4096)) === false) {
                    break;
                } else {
                    $line_num++;
                }
            }
            // Return response as array
            return $response;
        } elseif ($type == 'string') {
            // If string, loop and create string
            $response = '';
            while (!feof($this->handle)) {
                $response .= fgets($this->handle, 4096);
            }
            // Return response as string
            return $response;
        } else {
            // If anything else, return nothing but a true
            return true;
        }
    }