Net::B...::Entry(3pm)
π Net::B...::Entry(3pm) π
okay bestie so this is a page from the User Contributed Perl Documentation and honestly? it's giving networking icon. buckle up π
β¨ NAME β¨
Net::Bonjour::Entry β the support module for mDNS service discovery (that's Apple's Bonjour, iykyk) π¦
πΈ SYNOPSIS πΈ
use Net::Bonjour;
my $res = Net::Bonjour->new(<service>[, <protocol>]); $res->discover;
foreach my $entry ( $res->entries ) { print $entry->name, "\n"; }
π DESCRIPTION π
So Net::Bonjour::Entry is the module that manages all the entries that come back from an mDNS service discovery (Apple's Bonjour, yes that Bonjour). If you want the whole picture, go read Net::Bonjour β this one's the little sister that handles the individual entries π
π METHODS π
π«Ά new([<fqdn>])
Makes you a brand new Net::Bonjour::Entry object, slay. That optional argument? It sets the fully qualifed domain name (FQDN) of the entry. But real talk β if you're using the Net::Bonjour module normally, you will not need to build Net::Bonjour::Entry objects yourself, because they get created automatically during the discovery process. the module does it for you, periodt β¨
π¦ address
Hands you the IP address of the entry.
π all_attrs
Returns every current attribute, in the form of a hashed array.
π attribute(<attribute>)
Returns the attribute you asked for from the TXT record of the entry. TXT records are where the extra info lives, like the path for http. lowkey essential π
β dnsrr([<record type>])
Returns a DNS answer packet of the entry, and the output comes as a Net::DNS::Packet object. The record type is what resource record you want it to answer with, i.e. PTR, SRV, or TXT. The default? PTR.
π§ fetch
Reloads the entry's info via mDNS. a little refresh moment π
πΈ fqdn
Returns the fully qualifed domain name (FQDN) of the 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. With that fqdn example above, the name would be 'server'. But heads up: 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 the title of the web resource. it's giving "name is a vibe, not an address" π
π₯ port
Returns the TCP or UDP port of the entry.
π sockaddr
Returns the binary socket address for the resource, and you can use it directly to bind() sockets. no cap, that's the good stuff.
π EXAMPLES π
π Print out a list of local websites
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>";
π¦ Find a service and connect to it
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;
π SEE ALSO π
Net::Bonjour
π COPYRIGHT π
This library is free software and can be distributed or modified under the same terms as Perl itself. π
Bonjour (in this context) is a trademark of Apple Computer, Inc.
π« AUTHORS π«
The Net::Bonjour::Entry module was created by George Chlipala <george@walnutcs.com> β give him his flowers π
and that's the whole page bestie, no crumbs left β¨ this was perl v5.32.0, dated 2021-01-05, from the Net::B...::Entry(3pm) manual β mwah, go build something iconic π
π«Ά
π¦ where this page comes from
- debian bookworm: libnet-bonjour-perl 0.96-2.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libnet-bonjour-perl 0.96-2.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libnet-bonjour-perl 0.96-2.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnet-bonjour-perl 0.96-2.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-bonjour-perl 0.96-2.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-bonjour-perl 0.96-2.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms