Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$title is deprecated in /home/www/dev/work/website/lvesu/class/controller/blog/php.php on line 28

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/php.manual.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
PHP - Manual: Browsing devices and services - 互联网笔记

略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Browsing devices and services

2025-05-19

Browsing devices and services

This example shows how to obtain information about all devices and services. It starts an infinite loop (use CLI), and if any of available devices or services are found, the proper callback function will be invoked.

Example #1 Search for all UPnP devices and services.

<?php

/* Callback for available device */
function device_proxy_available_cb($proxy$arg)
{
    
$info gupnp_device_info_get($proxy);

    
$type $info['device_type'];
    
$location $info['location'];

    
printf("Device available:\n");
    
printf("\ttype:     %s\n"$type);
    
printf("\tlocation: %s\n"$location);
}

/* Callback for available service */
function service_proxy_available_cb($proxy$arg)
{
    
$info gupnp_service_info_get($proxy);

    
$type $info['service_type'];
    
$location $info['location'];

    
printf("Service available:\n");
    
printf("\ttype:     %s\n"$type);
    
printf("\tlocation: %s\n"$location);
}

/* Create the UPnP context */
$context gupnp_context_new();
if (!
$context) {
    
printf("Error creating the GUPnP context\n");
    exit(-
1);
}

/* We're interested in everything */
$cp gupnp_control_point_new($context"ssdp:all");

/* Set callbacks */
gupnp_control_point_callback_set($cp
    
GUPNP_SIGNAL_DEVICE_PROXY_AVAILABLE'device_proxy_available_cb');
gupnp_control_point_callback_set($cp
    
GUPNP_SIGNAL_SERVICE_PROXY_AVAILABLE'service_proxy_available_cb');

/* Start for browsing (infinite loop, hit Ctrl-C to interrupt) */
gupnp_control_point_browse_start($cp);

?>
add a note add a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/gupnp.browsing.php

冷却塔厂家 广告
中文GPT4.0无需注册 广告
北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3