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::Entry - Support module for mDNS service discovery (Apple's Rendezvous)

SYNOPSIS

use Net::Rendezvous;

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

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

DESCRIPTION

Net::Rendezvous::Entry is a module used to manage entries returned by a mDNS service discovery (Apple's Rendezvous). See Net::Rendezvous for more information.

METHODS

new([<fqdn>])

Creates a new Net::Rendezvous::Entry object. The optional argument defines the fully qualifed domain name (FQDN) of the entry. Normal usage of the Net::Rendezvous module will not require the construction of Net::Rendezvous::Entry objects, as they are automatically created during the discovery process.

fetch

Reloads the information for the entry via mDNS.

fqdn

Returns the fully qualifed domain name (FQDN) of entry. An example FQDN is server._afpovertcp._tcp.local

name

Returns the name of the entry. In the case of the previous example, the name would be 'server'. This name may not be the hostname of the server. For example, names for presence/tcp will be the name of the user and http/tcp will be title of the web resource.

hostname

Returns the short hostname of the server. For some services this may be different that the name.

address

Returns the IP address of the entry.

port

Returns the TCP or UDP port of the entry.

sockaddr

Returns the binary socket address for the resource and can be used directly to bind() sockets.

attribute(<attribute>)

Returns the specified attribute from the TXT record of the entry. TXT records are used to specify additional information, e.g. path for http.

EXAMPLES

        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 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

Net::Rendezvous

COPYRIGHT

This library is free software and can be distributed or modified under the same terms as Perl itself.

AUTHORS

The Net::Rendezvous::Entry module was created by George Chlipala <george@walnutcs.com>