Gupnp 函数
在线手册:中文  英文

gupnp_context_new

(PECL gupnp >= 0.1.0)

gupnp_context_newCreate a new context

说明

resource gupnp_context_new ([ string $host_ip [, int $port = 0 ]] )

Create a new context with the specified host_ip and port.

参数

host_ip

The local host's IP address, or NULL to use the IP address of the first non-loopback network interface.

port

Port to run on, or 0 if you don't care what port is used.

返回值

A context identifier.

范例

Example #1 Create new UPnP context

<?php

/* Create the UPnP context */
$context gupnp_context_new();

if (!
$context) {
 die(
"Error creating the GUPnP context\n");
}

?>

错误/异常

Issues E_WARNING with unable to create context.


Gupnp 函数
在线手册:中文  英文

用户评论:

flanker_forever at hotmail dot com (2012-04-27 09:04:18)

gupnp_context_new only allow you to use a specific network interface, not an ip address.
In gupnp-context.c we get :
gupnp_context_new (GMainContext *main_context, const char *interface, guint port, GError **error)
with @interface: The network interface to use, or %NULL to auto-detect.
ie use $context = gupnp_context_new("eth0");
NOT $context = gupnp_context_new("1.2.3.4");

易百教程