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.

Service

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

Creates the Service using the given information.

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.

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.

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".