Skip to content

Gio.NetworkService

class — extends GObject.Object, SocketConnectable

Like NetworkAddress does with hostnames, GNetworkService provides an easy way to resolve a SRV record, and then attempt to connect to one of the hosts that implements that service, handling service priority/weighting, multiple IP addresses, and multiple address families.

See SrvTarget for more information about SRV records, and see SocketConnectable for an example of using the connectable interface.

Constructors

new

@classmethod
def new(cls, service: str, protocol: str, domain: str) -> NetworkService

Creates a new NetworkService representing the given service, protocol, and domain. This will initially be unresolved; use the SocketConnectable interface to resolve it.

Parameters:

  • service — the service type to look up (eg, "ldap")
  • protocol — the networking protocol to use for service (eg, "tcp")
  • domain — the DNS domain to look up the service in

Methods

get_domain

def get_domain(self) -> str

Gets the domain that srv serves. This might be either UTF-8 or ASCII-encoded, depending on what srv was created with.

get_protocol

def get_protocol(self) -> str

Gets srv's protocol name (eg, "tcp").

get_scheme

def get_scheme(self) -> str

Gets the URI scheme used to resolve proxies. By default, the service name is used as scheme.

get_service

def get_service(self) -> str

Gets srv's service name (eg, "ldap").

set_scheme

def set_scheme(self, scheme: str) -> None

Set's the URI scheme used to resolve proxies. By default, the service name is used as scheme.

Parameters:

  • scheme — a URI scheme

Properties

domain

domain: str  # read/write

Network domain, for example example.com.

protocol

protocol: str  # read/write

Network protocol, for example tcp.

scheme

scheme: str  # read/write

Network scheme (default is to use service).

service

service: str  # read/write

Service name, for example ldap.