Class Protocols.DNS_SD.Service

Inheritance graph
_Protocols_DNS_SD.Service Protocols.DNS_SD.Service
Description

This class provides an interface to DNS Service Discovery. The functionality of DNS-SD is described at <http://www.dns-sd.org/>.

Using the Proctocols.DNS_SD.Service class a Pike program can announce services, for example a web site or a database server, to computers on the local network.

When registering a service you need to provide the service name. service type, domain and port number. You can also optionally specify a TXT record. The contents of the TXT record varies between different services; for example, a web server can announce a path to a web page, and a printer spooler is able to list printer features such as color support or two-sided printing.

The service is registered on the network for as long as the instance of the Service class is valid.


Inherit Service

inherit _Protocols_DNS_SD.Service : Service


Method create

Protocols.DNS_SD.Service Protocols.DNS_SD.Service(string name, string service, string domain, int port, void|string|array(string) txt)

Description

Registers a service on the local network.

Parameter name

User-presentable name of the service.

Parameter service

Type of service on the form _type._protocol. Type is an identifier related to the service type. A list of registered service types can be found at http://http://www.dns-sd.org/ServiceTypes.html/. Protocol is normally tcp but udp is also a valid choice. For example, a web server would get a service of _http._tcp.

Parameter domain

Domain name. Normally an empty string which the DNS-SD library will translate into local..

Parameter port

Port number for the service (e.g. 80 for a web site).

Parameter txt

An optional TXT record with service-specific information. It can be given as a plain string or an array of property assignment strings. The TXT record can be changed later by calling update_txt in the object returned when you register the service.

Example

object svc = Protocols.DNS_SD.Service( "Company Intranet Forum", // name "_http._tcp", // service type "", // domain (default) 80, // port ({ "path=/forum/" }) // TXT record );