KDNSSD 5.109.0
Public Types | Signals | Public Member Functions | Protected Member Functions | List of all members
KDNSSD::RemoteService

Describes a service published over DNS-SD, typically on a remote machine. More...

#include <KDNSSD/RemoteService>

Public Types

typedef QExplicitlySharedDataPointer< RemoteServicePtr
 
- Public Types inherited from KDNSSD::ServiceBase
typedef QExplicitlySharedDataPointer< ServiceBasePtr
 

Signals

void resolved (bool successful)
 Emitted when resolving is complete.
 

Public Member Functions

 RemoteService (const QString &name, const QString &type, const QString &domain)
 Creates an unresolved RemoteService representing the service with the given name, type and domain.
 
bool isResolved () const
 Whether the service has been successfully resolved.
 
bool resolve ()
 Resolves the host name and port of service synchronously.
 
void resolveAsync ()
 Resolves the host name and port of service asynchronously.
 
- Public Member Functions inherited from KDNSSD::ServiceBase
 ServiceBase (const QString &name=QString(), const QString &type=QString(), const QString &domain=QString(), const QString &host=QString(), unsigned short port=0)
 Creates a ServiceBase object.
 
QString domain () const
 The domain that the service belongs to.
 
QString hostName () const
 The hostname of the service.
 
bool operator!= (const ServiceBase &o) const
 Compares services based on name, type and domain.
 
bool operator== (const ServiceBase &o) const
 Compares services based on name, type and domain.
 
unsigned short port () const
 The port number of the service.
 
QString serviceName () const
 The name of the service.
 
QMap< QString, QByteArray > textData () const
 Additional text data associated with the service.
 
QString type () const
 The type of the service.
 

Protected Member Functions

void virtual_hook (int id, void *data) override
 
- Protected Member Functions inherited from KDNSSD::ServiceBase
KDNSSD_NO_EXPORT ServiceBase (ServiceBasePrivate *const d)
 
virtual void virtual_hook (int, void *)
 

Additional Inherited Members

- Protected Attributes inherited from KDNSSD::ServiceBase
std::unique_ptr< ServiceBasePrivate > const d
 

Detailed Description

Describes a service published over DNS-SD, typically on a remote machine.

This class allows delayed or asynchronous resolution of services. As the name suggests, the service is normally on a remote machine, but the service could just as easily be published on the local machine.

RemoteService instances are normally provided by ServiceBrowser, but can be used to resolve any service if you know the name, type and domain for it.

Author
Jakub Stachowski
See also
ServiceBrowser

Constructor & Destructor Documentation

◆ RemoteService()

KDNSSD::RemoteService::RemoteService ( const QString &  name,
const QString &  type,
const QString &  domain 
)

Creates an unresolved RemoteService representing the service with the given name, type and domain.

Parameters
namethe name of the service
typethe type of the service (see ServiceBrowser::ServiceBrowser())
domainthe domain of the service
See also
ServiceBrowser::isAvailable()

Member Function Documentation

◆ isResolved()

bool KDNSSD::RemoteService::isResolved ( ) const

Whether the service has been successfully resolved.

Returns
true if hostName() and port() will return valid values, false otherwise

◆ resolve()

bool KDNSSD::RemoteService::resolve ( )

Resolves the host name and port of service synchronously.

The host name is not resolved into an IP address - use KResolver for that.

resolved(bool) is emitted before this function is returned.

resolve() will not cause RemoteService to monitor for changes in the hostname or port of the service.

Returns
true if successful, false on failure
See also
resolveAsync(), hostName(), port()

◆ resolveAsync()

void KDNSSD::RemoteService::resolveAsync ( )

Resolves the host name and port of service asynchronously.

The host name is not resolved into an IP address - use KResolver for that.

The resolved(bool) signal will be emitted when the resolution is complete, or when it fails.

Note that resolved(bool) may be emitted before this function returns in case of immediate failure.

RemoteService will keep monitoring the service for changes in hostname and port, and re-emit resolved(bool) when either changes.

See also
resolve(), hostName(), port()

◆ resolved

void KDNSSD::RemoteService::resolved ( bool  successful)
signal

Emitted when resolving is complete.

If operating in asynchronous mode this signal can be emitted several times (when the hostName or port of the service changes).

Parameters
successfultrue if the hostName and port were successfully resolved, false otherwise

◆ virtual_hook()

void KDNSSD::RemoteService::virtual_hook ( int  id,
void *  data 
)
overrideprotectedvirtual

Reimplemented from KDNSSD::ServiceBase.