zeroconf.publish()

Type Function
Return value Userdata
Revision Release 2024.3703
Keywords ZeroConf, network, publish
See also zeroconf.unpublish()
zeroconf.unpublishAll()
zeroconf.*

Overview

Starts advertising a service over the network. This will also trigger a PluginZeroConfEvent event with a phase of "published".

If publishing is started successfully, a publish ID will be returned. This can be passed to zeroconf.unpublish() to un-publish the service.

Gotchas

This function returns nil in case of failure.

Syntax

zeroconf.publish( params )
params (required)

Table. Table containing parameters for the new object — see the next section for details.

Parameter Reference

port (required)

Number. Network port number to be advertised.

type (optional)

String. The type of service to publish. This must start with an underscore (_) and end with a protocol separated by a dot. Valid protocol names are _tcp and _udp. The default type is _corona._tcp.

name (optional)

String. This should identify a specific device. Passing an empty string (default) will trigger an attempt to generate a unique name.

data (optional)

Table. Arbitrary key-value data can be attached to the published service. Both data keys and values must be a string. Total size of all attached data is limited to 255 bytes.

domain (optional)

String. Domain to browse for services. Default is "local". An empty string indicates all available domains. Omit this key unless you fully understand its purpose.