The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::Rendezvous - Module for DNS service discovery (Apple's Rendezvous)

SYNOPSIS

        use Net::Rendezvous;
        
        my $res = Net::Rendezvous->new(<service>[, <protocol>]);

        $res->discover;

        foreach my $entry ( $res->entries ) {
                printf "%s %s:%s\n", $entry->name, $entry->address, $entry->port;
        }

Or the cyclical way:

        use Net::Rendezvous;

        my $res = Net::Rendezvous->new(<service>[, <protocol>]);
               
        $res->discover;

        while ( 1 ) {
           foreach my $entry ( $res->entries ) {
                   print $entry->name, "\n";
           }
           $res->discover;
        }

DESCRIPTION

Net::Rendezvous is a set of modules that allow one to discover local services via multicast DNS (mDNS) or enterprise services via traditional DNS. 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 DNS service discovery.

Entry Object

The base object (Net::Rendezvous) will return entry objects of the class Net::Rendezvous::Entry.

METHODS

new([<service>, <protocol>, <domain>])

Creates a new Net::Rendezvous discovery object. First argument specifies the service to discover, e.g. http, ftp, afpovertcp, and ssh. The second argument specifies the protocol, i.e. tcp or udp. The default protocol is TCP. The third argument specifies the discovery domain, the default is 'local'.

If no argments are specified, the resulting Net::Rendezvous object will be empty and will not perform an automatic discovery upon creation.

domain([<domain>])

Get/sets current discovery domain. By default, the discovery domain is 'local'. Discovery for the 'local' domain is done via MDNS while all other domains will be done via traditional DNS.

discover

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 "<HTML><TITLE>Local Websites</TITLE>";
        
        use Net::Rendezvous;

        my $res = Net::Rendezvous->new('http');
        $res->discover;

        foreach my $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 = Net::Rendezvous->new('custom');
        $res->discover;
        
        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

Net::Rendezvous::Entry

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>