Poco::DNSSD

class Service

Library: DNSSD
Package: Core
Header: Poco/DNSSD/Service.h

Description

Service holds information for a registered or resolved service.

Member Summary

Member Functions: domain, fullName, host, name, networkInterface, port, properties, type

Types

Properties

typedef Poco::Net::NameValueCollection Properties;

The Properties of a resolved service contains the contents of the associated TXT record.

The TXT record contains key-value pairs in the form <key>=<value>. Each pair is preceded by a length byte giving the total length of the pair. Thus the total length of key plus value must not exceed 254 bytes. Keys are case insensitive and must consists entirely of printable US-ASCII characters. The length of a key should not exceed nine bytes, to keep packet sizes small. Values can contain arbitrary bytes. A value can also be empty; in this case the '=' character can be omitted in the record.

Constructors

Service

Service();

Creates an empty Service.

Service

Service(
    const std::string & type,
    Poco::UInt16 port,
    const Properties & properties = Properties ()
);

Creates the Service using the given information. This is the easiest way to create a Service instance for registration.

The service will be registered on all available network interfaces. The computer's name will be used as the service name. The default domain is used, and the computer's host name is used as host name for registering.

  • type specifies the registration type of the service, consisting of service type and network protocol (delimited by a dot, as in "_ftp._tcp"), and an optional subtype (e.g., "_primarytype._tcp,_subtype"). The protocol is always either "_tcp" or "_udp".
  • properties contains the contents of the service's TXT record.

Service

Service(
    Poco::Int32 networkInterface,
    const std::string & name,
    const std::string & type,
    const std::string & domain
);

Creates the Service using the given information.

  • networkInterface specifies the index of the interface the service was discovered on. When registering a service, can be set to 0 to register the service on all available interfaces.
  • name specifies the human-readable service name. When registering a service, can be left empty. In this case the computer's name is used. Must be 1 - 63 bytes of UTF-8 text.
  • type specifies the registration type of the service, consisting of service type and network protocol (delimited by a dot, as in "_ftp._tcp"), and an optional subtype (e.g., "_primarytype._tcp,_subtype"). The protocol is always either "_tcp" or "_udp".
  • domain specifies the name of the domain the service is registered on. When registering a service, can be left empty to register in the default domain.

Service

Service(
    Poco::Int32 networkInterface,
    const std::string & name,
    const std::string & fullName,
    const std::string & type,
    const std::string & domain,
    const std::string & host,
    Poco::UInt16 port
);

Creates the Service using the given information.

  • networkInterface specifies the index of the interface the service was discovered on. When registering a service, can be set to 0 to register the service on all available interfaces.
  • name specifies the human-readable service name. When registering a service, can be left empty. In this case the computer's name is used. Must be 1 - 63 bytes of UTF-8 text.
  • fullName specifies the full service name in the form "<servicename>.<protocol>.<domain>.". When registering a service, this should be left empty.
  • type specifies the registration type of the service, consisting of service type and network protocol (delimited by a dot, as in "_ftp._tcp"), and an optional subtype (e.g., "_primarytype._tcp,_subtype"). The protocol is always either "_tcp" or "_udp".
  • domain specifies the name of the domain the service is registered on. When registering a service, can be left empty to register in the default domain.
  • host specifies the name of the host providing the service. When registering a service, can be left empty to use the machine's default host name.
  • port specifies the port number on which the service is available.

Service

Service(
    Poco::Int32 networkInterface,
    const std::string & name,
    const std::string & fullName,
    const std::string & type,
    const std::string & domain,
    const std::string & host,
    Poco::UInt16 port,
    const Properties & properties
);

Creates the Service using the given information.

  • networkInterface specifies the index of the interface the service was discovered on. When registering a service, can be set to 0 to register the service on all available interfaces.
  • name specifies the human-readable service name. When registering a service, can be left empty. In this case the computer's name is used. Must be 1 - 63 bytes of UTF-8 text.
  • fullName specifies the full service name in the form "<servicename>.<protocol>.<domain>.". When registering a service, this should be left empty.
  • type specifies the registration type of the service, consisting of service type and network protocol (delimited by a dot, as in "_ftp._tcp"), and an optional subtype (e.g., "_primarytype._tcp,_subtype"). The protocol is always either "_tcp" or "_udp".
  • domain specifies the name of the domain the service is registered on. When registering a service, can be left empty to register in the default domain.
  • host specifies the name of the host providing the service. When registering a service, can be left empty to use the machine's default host name.
  • port specifies the port number on which the service is available.
  • properties contains the contents of the service's TXT record.

Destructor

~Service

~Service();

Destroys the Service.

Member Functions

domain inline

const std::string & domain() const;

The domain the service is registered on.

fullName inline

const std::string & fullName() const;

Returns the full name of the service.

The format of the full name is "<servicename>.<protocol>.<domain>.". This name is escaped following standard DNS rules. The full name will be empty for an unresolved service.

host inline

const std::string & host() const;

Returns the host name of the host providing the service.

Will be empty for an unresolved service.

name inline

const std::string & name() const;

The name of the service.

networkInterface inline

Poco::Int32 networkInterface() const;

The id of the interface on which the remote service is running, or zero if the service is available on all interfaces.

port inline

Poco::UInt16 port() const;

Returns the port number on which the service is available.

Will be 0 for an unresolved service.

properties inline

const Properties & properties() const;

Returns the contents of the TXT record associated with the service.

Will be empty for an unresolved service.

properties

Properties & properties();

Returns the contents of the TXT record associated with the service.

Will be empty for an unresolved service.

type inline

const std::string & type() const;

The registration type of the service, consisting of service type and network protocol (delimited by a dot, as in "_ftp._tcp"), and an optional subtype (e.g., "_primarytype._tcp,_subtype").

The protocol is always either "_tcp" or "_udp".

Securely control IoT edge devices from anywhere   Connect a Device