.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Net::Bonjour 3pm" .TH Net::Bonjour 3pm "2009-02-28" "perl v5.10.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::Bonjour \- Module for DNS service discovery (Apple's Bonjour) .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Net::Bonjour; \& \& my $res = Net::Bonjour\->new([, ]); \& \& $res\->discover; \& \& foreach my $entry ( $res\->entries ) { \& printf "%s %s:%s\en", $entry\->name, $entry\->address, $entry\->port; \& } .Ve .PP Or the cyclical way: .PP .Vb 1 \& use Net::Bonjour; \& \& my $res = Net::Bonjour\->new([, ]); \& \& $res\->discover; \& \& while ( 1 ) { \& foreach my $entry ( $res\->entries ) { \& print $entry\->name, "\en"; \& } \& $res\->discover; \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Net::Bonjour is a set of modules that allow one to discover local services via multicast \s-1DNS\s0 (mDNS) or enterprise services via traditional \s-1DNS\s0. This method of service discovery has been branded as Bonjour by Apple Computer. .SS "Base Object" .IX Subsection "Base Object" The base object would be of the Net::Bonjour class. This object contains the resolver for \s-1DNS\s0 service discovery. .SS "Entry Object" .IX Subsection "Entry Object" The base object (Net::Bonjour) will return entry objects of the class Net::Bonjour::Entry. .SH "METHODS" .IX Header "METHODS" .SS "new([, , ])" .IX Subsection "new([, , ])" Creates a new Net::Bonjour 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. \&\fIThe default protocol is \s-1TCP\s0\fR. The third argument specifies the discovery domain, the default is 'local'. .PP If no arguments are specified, the resulting Net::Bonjour object will be empty and will not perform an automatic discovery upon creation. .SS "all_services([])" .IX Subsection "all_services([])" Returns an array of new Net::Renedezvous objects for each service type advertised in the domain. The argument specifies the discovery domain, the default is 'local'. Please note that the resulting Net::Bonjour objects will not have performed a discovery during the creation. Therefore, the discovery process will need to be run prior to retriving a list of entries for that Net::Bonjour object. .SS "domain([])" .IX Subsection "domain([])" Get/sets current discovery domain. By default, the discovery domain is 'local'. Discovery for the 'local' domain is done via \s-1MDNS\s0 while all other domains will be done via traditional \s-1DNS\s0. .SS "discover" .IX Subsection "discover" Repeats the discovery process and reloads the entry list from this discovery. .SS "entries" .IX Subsection "entries" Returns an array of Net::Renedezvous::Entry objects for the last discovery. .SS "protocol([])" .IX Subsection "protocol([])" Get/sets current protocol of the service type, i.e. \s-1TCP\s0 or \s-1UDP\s0. Please note that this is not the protocol for \&\s-1DNS\s0 connection. .SS "service([])" .IX Subsection "service([])" Get/sets current service type. .SS "shift_entry" .IX Subsection "shift_entry" Shifts off the first entry of the last discovery. The returned object will be a Net::Bonjour::Entry object. .SH "EXAMPLES" .IX Header "EXAMPLES" .SS "Print out a list of local websites" .IX Subsection "Print out a list of local websites" .Vb 1 \& print "Local Websites"; \& \& use Net::Bonjour; \& \& my $res = Net::Bonjour\->new(\*(Aqhttp\*(Aq); \& $res\->discover; \& \& foreach my $entry ( $res\->entries) { \& printf "%s
", $entry\->address, \& $entry\->attribute(\*(Aqpath\*(Aq), $entry\->name; \& } \& \& print ""; .Ve .SS "Find a service and connect to it" .IX Subsection "Find a service and connect to it" .Vb 2 \& use Socket; \& use Net::Bonjour; \& \& my $res = Net::Bonjour\->new(\*(Aqcustom\*(Aq); \& $res\->discover; \& \& my $entry = $res\->shift_entry; \& \& socket SOCK, PF_INET, SOCK_STREAM, scalar(getprotobyname(\*(Aqtcp\*(Aq)); \& \& connect SOCK, $entry\->sockaddr; \& \& print SOCK "Send a message to the service"; \& \& while ($line = ) { print $line; } \& \& close SOCK; .Ve .SS "Find all service types and print." .IX Subsection "Find all service types and print." .Vb 1 \& use Net::Bonjour; \& \& foreach my $res ( Net::Bonjour\->all_services ) { \& printf "%s (%s)\en", $res\->service, $res\->protocol; \& } .Ve .SS "Find and print all service types and entries." .IX Subsection "Find and print all service types and entries." .Vb 1 \& use Net::Bonjour; \& \& foreach my $res ( Net::Bonjour\->all_services ) { \& printf "\-\- %s (%s) \-\-\-\en", $res\->service, $res\->protocol; \& $res\->discover; \& foreach my $entry ( $res\->entries) { \& printf "\et%s (%s:%s)\en", $entry\->name, $entry\->address, $entry\->port; \& } \& } .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Net::Bonjour::Entry .SH "COPYRIGHT" .IX Header "COPYRIGHT" This library is free software and can be distributed or modified under the same terms as Perl itself. .PP Bonjour (in this context) is a trademark of Apple Computer, Inc. .SH "AUTHORS" .IX Header "AUTHORS" The Net::Bonjour module was created by George Chlipala