Bonjour

Apple Computer's implementation of the ZeroConf [L1 ] network configuration and service discovery protocol, formerly known as Rendezvous.

A Tcl package for Bonjour is available at http://github.com/dongola7/tcl_bonjour/ .


lordmundi: This is a great package. I think many people may be missing it since they are searching for things like "DNS-SD" or DNS Service Discovery, or mDNS. To help out these keyword based google searches, this package will let you do DNS service discovery browsing, publishing, and resolving in tcl. If you aren't familiar with DNS-SD, you can learn more about it here:

http://en.wikipedia.org/wiki/Zero_configuration_networking


lordmundi (2011-03-11): As a hint for anyone using the package - the returned service name, when doing a resolve, has escaped characters so that it can be passed into other functions of the bonjour api directly. However, if you are like me and want to give the service name back to the user in a gui or prompt, you may not want to see something like this:

 kramer\032\09100\05826\05818\058fc\0588f\05809\093._workstation._tcp.local.

the solution is to run it through a quick function to make the name more readable, (although you may want to hang on to the encoded string also). A great discussion on this page yielded this nice function:

 proc get_printable_name { encoded_name } { 
     return [ subst [ regsub -all {\\([0-9]{3})} $encoded_name {[format %c [scan "\1" %d]]} ] ]
 }

which would give you:

 % get_printable_name {kramer\032\09100\05826\05818\058fc\0588f\05809\093._workstation._tcp.local.}
 kramer [00:26:18:fc:8f:09]._workstation._tcp.local.

Hope that helps someone.


bll 2017-6-18 :( Cannot build this on windows due to the use of Tcl_(Create|Delete)FileHandler

This script can be used to build the package in msys2 without the browser or resolver.

First, #include <arpa/inet.h> must be replaced with #include <Winsock2.h> in generic/*.c

sed -i -e '/Browse_Init/ s,/\*,,;/Browse_Init/ s,\*/,,;/Browse_Init/ s,^,/*,;/Browse_Init/ s,$,*/,' \
        -e '/Resolve_Init/ s,/\*,,;/Resolve_Init/ s,\*/,,;/Resolve_Init/ s,^,/*,;/Resolve_Init/ s,$,*/,' \
        generic/bonjour.c
./configure --with-tcl=/home/bll/local-64/lib \
        CFLAGS="-static -m64 -I/c/PROGRA~1/BONJOU~1/Include" \
        LIBS="/c/PROGRA~1/BONJOU~1/Lib/x64/dnssd.lib -lws2_32" \
        SHLIB_LD="gcc -m64 -shared -static-libgcc"
sed -i -e '/^PKG_OBJECTS/ s/browse.o//;s/resolve.o//' \
        Makefile
make clean
make
mv -f libbonjour1.1 libbonjour1.1.dll