This package provides script level access to the Bonjour library. Bonjour allows registration of network services so that they can easily be located by name and/or browsed for by service type.
The bonjour package currently supports browsing for services, service name resolution, and service registration.
The bonjour package is written and maintained on OS X, but is known to work on various Linux distributions by using the Avahi compatibility libraries.
If you already have MacPorts installed on your OS X system, you can install the latest version of tcl_bonjour via the command: sudo port install tcl_bonjour
.
See http://macports.org for additional information on MacPorts.
If you’re using Homebrew, I maintain a tap containing a formula for tcl_bonjour. You can install using the following commands: brew tap dongola7/dongola7; brew install tcl_bonjour
.
See http://mxcl.github.com/homebrew/ for additional information on Homebrew.
The bonjour package may be installed using the standard configure; make; make install
procedure.
The bonjour package provides the following commands:
::bonjour::browse start <regtype> <callback>
– This procedue begins a browse operation for a given service type. Every time a service is added or removed to the list of running services,callback
will be executed.regtype
– The service type to browse (i.e.,_http._tcp
)callback
– The command to call when a service is added or removed from the list of running services. Three arguments will be appended to the command:- the action (either
add
orremove
) - the service name
- the domain
- the action (either
::bonjour::browse stop <regtype>
– This procedure stops a browse operation. The callback registered forregtype
will no longer be called and no new services will be aded.regtype
– The service type (i.e.,_http._tcp
)
::bonjour::resolve <name> <regtype> <domain> <script>
– This procedure resolves the given service name into a hostname and port.name
– The name of the service to resolveregtype
– The service type (i.e.,_http._tcp
)domain
– The domain for the service, as returned by the browse callback.script
– The script to execute when the resolution has completed. Four arguments will be appended to the callback script:- The full service name
- The hostname
- The port
- a list of txt records for the service. The list of records will be of the form
{key value ?key value? ...}
.
::bonjour::resolve_address <name> <script>
– This procedure resolves the address of the given service name.name
– the service namescript
– The script to execute when the resolution has completed. The IP address will be appended to the callback script.
::bonjour::register ?options? <regtype> <port> ?txt-record?
– This procedure registers a new service using Bonjour.options
– Either \-name, followed by the desired service name, or \-\- to explicitly indicate the end of options.regtype
– The service type (i.e.,_http._tcp
)port
– The port number for the servicetxt-record
– This argument is optional and specifies a list of txt record entries. The list should be of the form{key value ?key value? ...}
.
Please report all bugs and feature requests via the GitHub issue tracker at http://github.com/dongola7/tcl_bonjour/issues.