logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Net::Bonjour::Entry - Support module for mDNS service discovery (Apple's Bonjour)

Authors

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

perl v5.32.0                                       2021-01-05                           Net::Bonjour::Entry(3pm)

Description

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

Examples

Printoutalistoflocalwebsites
               print "<HTML><TITLE>Local Websites</TITLE>";

               use Net::Bonjour;

               my $res = Net::Bonjour->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>";

   Findaserviceandconnecttoit
               use Net::Bonjour;

               my $res = Net::Bonjour->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;

Methods

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

   address
       Returns the IP address of the entry.

   all_attrs
       Returns all the current attributes in the form of hashed array.

   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.

   dnsrr([<recordtype>])
       Returns an DNS answer packet of the entry.  The output will be in the format of a Net::DNS::Packet
       object.  The recordtype designates the resource record to answer with, i.e. PTR, SRV, or TXT.  The
       default is PTR.

   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

   hostname
       Returns the hostname of the server, e.g. 'server.local'.

   name
       Returns the name of the entry.  In the case of the fqdn 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.

   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.

Name

       Net::Bonjour::Entry - Support module for mDNS service discovery (Apple's Bonjour)

See Also

       Net::Bonjour

Synopsis

       use Net::Bonjour;

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

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

See Also