NAME
Net::Rendezvous - Module for mDNS service discovery (Apple's Rendezvous)
SYNOPSIS
use Net::Rendezvous;
my $res = new Net::Rendezvous(<service>[, <protocol>]);
foreach $entry ( $res->entries ) {
printf "%s %s:%s\n", $entry->name, $entry->address,
$entry->port;
}
Or the cyclical way:
use Net::Rendezvous;
my $res = new Net::Rendezvous(<service>[, <protocol>]);
while ( 1 ) {
foreach $entry ( $res->entries ) {
print $entry->name, "\n";
}
$res->refresh;
}
DESCRIPTION
Net::Rendezvous is a set of modules that allow one to discover local services via multicast DNS (mDNS). This method of service discovery has been branded as Rendezvous by Apple Computer.
Base Object
The base object would be of the Net::Rendezvous class. This object contains the resolver for mDNS service discovery.
Entry Object
The base object (Net::Rendezvous) will return entry objects of the class Net::Rendezvous::Entry.
METHODS
new(<service>[, <protocol>])
Creates a new Net::Rendezvous discovery object. First argument (required) specifies the service to discover, e.g. http, ftp, afpovertcp, and ssh. The second argument (optional) specifies the protocol, i.e. tcp or udp. The default protocol is TCP.
refresh
Repeats the discovery process and reloads the entry list from this discovery.
entries
Returns an array of Net::Renedezvous::Entry objects for the last discovery.
shift_entry
Shifts off the first entry of the last discovery. The returned object will be a Net::Rendezvous::Entry object.
EXAMPLES
Print out a list of local websites
print "<HTML><TITLE>Local Websites</TITLE>";
use Net::Rendezvous;
my $res = new Net::Rendezvous('http');
foreach $entry ( $res->entries) {
printf "<A HREF='http://%s%s'>%s</A><BR>", $entry->address,
$entry->attribute('path'), $entry->name;
}
print "</HTML>";
Find a service and connect to it
use Socket;
use Net::Rendezvous;
my $res = new Net::Rendezvous('custom');
my $entry = $res->shift_entry;
socket SOCK, PF_INET, SOCK_STREAM, scalar(getprotobyname('tcp'));
connect SOCK, $entry->sockaddr;
print SOCK "Send a message to the service";
while ($line = <SOCK>) { print $line; }
close SOCK;
SEE ALSO
COPYRIGHT
This library is free software and can be distributed or modified under the same terms as Perl itself.
Rendezvous (in this context) is a trademark of Apple Computer, Inc.
AUTHORS
The Net::Rendezvous module was created by George Chlipala <george@walnutcs.com>