GSSDP.Client

g GObject.GInterface GObject.GInterface Gio.Initable Gio.Initable GObject.GInterface->Gio.Initable GObject.Object GObject.Object GSSDP.Client GSSDP.Client GObject.Object->GSSDP.Client Gio.Initable->GSSDP.Client

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gio.Initable (2)

Structs:

GObject.ObjectClass (5)

class

new (iface)

class

new_for_address (addr, port, uda_version)

class

new_full (iface, addr, port, uda_version)

class

new_with_port (iface, msearch_port)

add_cache_entry (ip_address, user_agent)

append_header (name, value)

can_reach (address)

clear_headers ()

get_active ()

get_address ()

get_address_mask ()

get_family ()

get_host_ip ()

get_index ()

get_interface ()

get_network ()

get_port ()

get_server_id ()

get_uda_version ()

guess_user_agent (ip_address)

remove_header (name)

set_boot_id (boot_id)

set_config_id (config_id)

set_network (network)

set_server_id (server_id)

Virtual Methods

Inherited:

GObject.Object (7), Gio.Initable (1)

Properties

Name

Type

Flags

Short Description

active

bool

r/w

True if the client is active.

address

Gio.InetAddress

r/w/co

The internet address of the client

address-family

Gio.SocketFamily

r/w/co

IP address family to prefer when creating the client

boot-id

int

r/w/c

Value of the BOOTID.UPNP.ORG header

config-id

int

r/w/c

Value of the CONFIGID.UPNP.ORG header

host-ip

str

r/w/co

The IP address of the associatednetwork interface deprecated

host-mask

Gio.InetAddressMask

r/w/co

The IP netmask of the associatednetwork interface

interface

str

r/w/co

The name of the associated network interface.

msearch-port

int

r/w/co

UDP port to use for M-SEARCH requests deprecated

network

str

r/w/co

The network this client is currently connected to.

port

int

r/w/co

UDP port to use for M-SEARCH requests

server-id

str

r/w

The SSDP server’s identifier.

socket-ttl

int

r/w/co

Time To Live for client’s sockets

uda-version

GSSDP.UDAVersion

r/w/co

UPnP Device Architecture version on this client

Signals

Inherited:

GObject.Object (1)

Name

Short Description

message-received

Internal signal.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class GSSDP.Client(**kwargs)
Bases:

GObject.Object, Gio.Initable

Abstract:

No

Structure:

GSSDP.ClientClass

A simple SSDP bus handler.

The [classGSSDP.Client] will usually be used by the [classGSSDP.ResourceGroup] for announcing or the [classGSSDP.ResourceBrowser] for finding resources on the network.

A GSSDP.Client is required per IP address that you want to use, even if those belong t the same network device.

classmethod new(iface)
Parameters:

iface (str or None) – The name of the network interface, or None for auto-detection.

Raises:

GLib.Error

Returns:

A new GSSDP.Client object.

Return type:

GSSDP.Client or None

Creates a GSSDP client on iface. GSSDP.Client will pick the address it finds suitable for using.

Using this utility function, the created client will be using UDA 1.0 and IPv4 only.

Deprecated since version 1.6.: Use [ctorGSSDP.Client.new_for_address] instead.

classmethod new_for_address(addr, port, uda_version)
Parameters:
  • addr (Gio.InetAddress or None) – an IP address or None for auto-detection. If you do not care about the address, but want to specify an address family, use [ctor`Glib`.InetAddress.new_any] with the appropriate family instead.

  • port (int) – The network port to use for M-SEARCH requests or 0 for random.

  • uda_version (GSSDP.UDAVersion) – The UDA version this client will adhere to

Raises:

GLib.Error

Returns:

A new GSSDP.Client object or None on error.

Return type:

GSSDP.Client or None

Creates a GSSDP client with address addr. If none is specified, GSSDP will chose the address it deems most suitable.

New in version 1.6..

classmethod new_full(iface, addr, port, uda_version)
Parameters:
  • iface (str or None) – the name of a network interface

  • addr (Gio.InetAddress or None) – an IP address or None for auto-detection. If you do not care about the address, but want to specify an address family, use [ctor`Glib`.InetAddress.new_any] with the appropriate family instead.

  • port (int) – The network port to use for M-SEARCH requests or 0 for random.

  • uda_version (GSSDP.UDAVersion) – The UDA version this client will adhere to

Raises:

GLib.Error

Returns:

A new GSSDP.Client object or None on error.

Return type:

GSSDP.Client or None

Creates a GSSDP client with address addr. If none is specified, GSSDP will chose the address it deems most suitable.

New in version 1.6..

classmethod new_with_port(iface, msearch_port)
Parameters:
  • iface (str or None) – The name of the network interface, or None for auto-detection.

  • msearch_port (int) – The network port to use for M-SEARCH requests or 0 for random.

Raises:

GLib.Error

Returns:

A new GSSDP.Client object or None on error.

Return type:

GSSDP.Client or None

Creates a GSSDP client on iface. GSSDP.Client will pick the address it finds suitable for using.

Using this utility function, the created client will be using UDA 1.0 and IPv4 only.

Deprecated since version 1.6.: Use [ctorGSSDP.Client.new_for_address] instead.

add_cache_entry(ip_address, user_agent)
Parameters:
  • ip_address (str) – The host to add to the cache

  • user_agent (str) – User agent ot the host to add

Add user_agent for ip_address.

Each [classGSSDP.Client] maintains a mapping of addresses (MAC on systems that support it, IP addresses otherwise) to User Agents.

This information can be used in higher layers to get an User-Agent for devices that do not set the User-Agent header in their SOAP requests.

append_header(name, value)
Parameters:
  • name (str) – Header name

  • value (str or None) – Header value

Adds a header field to the messages sent by this self. It is intended to be used by clients requiring vendor specific header fields.

If there is an existing header with name it will append another one.

can_reach(address)
Parameters:

address (Gio.InetSocketAddress) – A Gio.InetSocketAddress of the target. The port part of the address may be 0

Returns:

True if considered reachable, False otherwise.

Return type:

bool

Check if the peer at address is reachable using this self.

New in version 1.2.4.

clear_headers()

Removes all the headers for this self.

get_active()
Returns:

True if self is active, False otherwise.

Return type:

bool

Get the current state of the client. See [propertyGSSDP.Client:active] for details.

get_address()
Returns:

The Gio.InetAddress this client works on

Return type:

Gio.InetAddress

The IP address this client works on.

get_address_mask()
Returns:

Address mask of this client

Return type:

Gio.InetAddressMask

New in version 1.2.3.

get_family()
Returns:

IP protocol version (Gio.SocketFamily.IPV4 or Gio.SocketFamily.IPV6) this client uses

Return type:

Gio.SocketFamily

get_host_ip()
Returns:

The IP address. This string should not be freed.

Return type:

str

Get the IP address we advertise ourselves as using.

get_index()
Returns:

The interface index of this client

Return type:

int

get_interface()
Returns:

The network interface name. This string should not be freed.

Return type:

str

Get the name of the network interface associated to self.

get_network()
Returns:

The network identification. This string should not be freed.

Return type:

str

Get the network identifier of the client. See [propertyGSSDP.Client:network] for details.

get_port()
Return type:

int

get_server_id()
Returns:

The server ID.

Return type:

str

get_uda_version()
Returns:

the UDA protocol version this client adheres to

Return type:

GSSDP.UDAVersion

guess_user_agent(ip_address)
Parameters:

ip_address (str) – IP address to guess the user-agent for

Returns:

The User-Agent cached for this IP, None if none is cached.

Return type:

str

Try to get a User-Agent for ip_address.

remove_header(name)
Parameters:

name (str) – Header name

Removes name from the list of headers. If there are multiple values for name, they are all removed.

set_boot_id(boot_id)
Parameters:

boot_id (int) – The new boot-id for the client

Will set the new boot-id for this SSDP client. Does nothing if the UDA version used by the client is UDA 1.0

The boot-id is used to signalize changes in the network configuration for multi-homed hosts

set_config_id(config_id)
Parameters:

config_id (int) – The new config-id for the client

The config-id is used to allow caching of the device or service description. It should be changed if that changes.

set_network(network)
Parameters:

network (str) – The string identifying the network

Sets the network identification of self to network.

set_server_id(server_id)
Parameters:

server_id (str) – The server ID

Sets the server ID of self to server_id. This string is used as the “Server:” identification header for SSDP discovery and response packets and “User-Agent” header for searches.

By default, GSSDP will generate a header conforming to the requirements defined in the UDA documents: OS/Version UPnP/Version GSSDP/Version.

Signal Details

GSSDP.Client.signals.message_received()
Signal Name:

message-received

Flags:

RUN_LAST

Internal signal.

Property Details

GSSDP.Client.props.active
Name:

active

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE

Whether this client is active or not (passive). When active (default), the client sends messages on the network, otherwise not. In most cases, you don’t want to touch this property.

GSSDP.Client.props.address
Name:

address

Type:

Gio.InetAddress

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The network address this client is bound to.

New in version 1.6.

GSSDP.Client.props.address_family
Name:

address-family

Type:

Gio.SocketFamily

Default Value:

Gio.SocketFamily.INVALID

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The IP protocol address family this client works on. When specified during construction without giving a concrete address, it will be used to determine the proper address.

If not specified, will contain the currrent address family after the call to [method`Glib`.Initable.init]. Use Gio.SocketFamily.INVALID to specifiy using the default socket family (legacy IP)

New in version 1.2.0.

GSSDP.Client.props.boot_id
Name:

boot-id

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE, CONSTRUCT

The value of the BOOTID.UPNP.ORG header

New in version 1.2.0.

GSSDP.Client.props.config_id
Name:

config-id

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE, CONSTRUCT

The value of the CONFIGID.UPNP.ORG header

New in version 1.2.0.

GSSDP.Client.props.host_ip
Name:

host-ip

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The IP address of the assoicated network interface.

Deprecated since version 1.6.: Use [propertyGSSDP.Client:address] instead.

GSSDP.Client.props.host_mask
Name:

host-mask

Type:

Gio.InetAddressMask

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The network mask of the assoicated network interface.

GSSDP.Client.props.interface
Name:

interface

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The name of the network interface this client is associated with. Set to None to autodetect.

GSSDP.Client.props.msearch_port
Name:

msearch-port

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

UDP port to use for sending multicast M-SEARCH requests on the network. If not set (or set to 0) a random port will be used. This property can be only set during object construction.

Deprecated since version 1.6.0: Use [propertyGSSDP.Client:port] instead

GSSDP.Client.props.network
Name:

network

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The network this client is currently connected to. You could set this to anything you want to identify the network this client is associated with. If you are using #GUPnPContextManager and associated interface is a WiFi interface, this property is set to the ESSID of the network. Otherwise, expect this to be the network IP address by default.

GSSDP.Client.props.port
Name:

port

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

UDP port to use for sending multicast M-SEARCH requests on the network. If not set (or set to 0) a random port will be used. This property can be only set during object construction.

New in version 1.6.0.

GSSDP.Client.props.server_id
Name:

server-id

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The SSDP server’s identifier.

GSSDP.Client.props.socket_ttl
Name:

socket-ttl

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Time-to-live value to use for all sockets created by this client. If not set (or set to 0) the value recommended by UPnP will be used. This property can only be set during object construction.

GSSDP.Client.props.uda_version
Name:

uda-version

Type:

GSSDP.UDAVersion

Default Value:

GSSDP.UDAVersion.VERSION_1_0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The UPnP version the client adheres to.

New in version 1.2.0.