ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent/DNS.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent/DNS.pm (file contents):
Revision 1.19 by root, Fri May 23 23:37:13 2008 UTC vs.
Revision 1.20 by root, Fri May 23 23:44:55 2008 UTC

27use strict; 27use strict;
28 28
29use AnyEvent::Handle (); 29use AnyEvent::Handle ();
30 30
31=item AnyEvent::DNS::addr $node, $service, $proto, $family, $type, $cb->([$family, $type, $proto, $sockaddr], ...) 31=item AnyEvent::DNS::addr $node, $service, $proto, $family, $type, $cb->([$family, $type, $proto, $sockaddr], ...)
32
33NOT YET IMPLEMENTED
34 32
35Tries to resolve the given nodename and service name into protocol families 33Tries to resolve the given nodename and service name into protocol families
36and sockaddr structures usable to connect to this node and service in a 34and sockaddr structures usable to connect to this node and service in a
37protocol-independent way. It works remotely similar to the getaddrinfo 35protocol-independent way. It works remotely similar to the getaddrinfo
38posix function. 36posix function.
47 45
48C<$proto> must be a protocol name, currently C<tcp>, C<udp> or 46C<$proto> must be a protocol name, currently C<tcp>, C<udp> or
49C<sctp>. The default is C<tcp>. 47C<sctp>. The default is C<tcp>.
50 48
51C<$family> must be either C<0> (meaning any protocol is ok), C<4> (use 49C<$family> must be either C<0> (meaning any protocol is ok), C<4> (use
52only IPv4) or C<6> (use only IPv6). 50only IPv4) or C<6> (use only IPv6). This setting might be influenced by
51C<$ENV{PERL_ANYEVENT_PROTOCOLS}>.
53 52
54C<$type> must be C<SOCK_STREAM>, C<SOCK_DGRAM> or C<SOCK_SEQPACKET> (or 53C<$type> must be C<SOCK_STREAM>, C<SOCK_DGRAM> or C<SOCK_SEQPACKET> (or
55C<undef> in which case it gets automatically chosen). 54C<undef> in which case it gets automatically chosen).
56 55
57The callback will receive zero or more array references that contain 56The callback will receive zero or more array references that contain
191 190
192 resolver->resolve ($domain => "*", $cb); 191 resolver->resolve ($domain => "*", $cb);
193} 192}
194 193
195############################################################################# 194#############################################################################
196
197#AnyEvent::DNS::addr $node, $service, $family, $type, $proto, $cb->([$family, $type, $protocol, $sockaddr], ...)
198 195
199# $port, $host 196# $port, $host
200sub pack_sockaddr_in6($$) { 197sub pack_sockaddr_in6($$) {
201 pack "nnN a16 N", 198 pack "nnN a16 N",
202 Socket::AF_INET6, 199 Socket::AF_INET6,
213 $family != 6 210 $family != 6
214 or return $cb->(); 211 or return $cb->();
215 212
216 $family ||= 4; 213 $family ||= 4;
217 } 214 }
215
216 $cb->() if $family == 4 && !$AnyEvent::PROTOCOL{ipv4};
217 $cb->() if $family == 6 && !$AnyEvent::PROTOCOL{ipv6};
218
219 $family ||=4 unless $AnyEvent::PROTOCOL{ipv6};
220 $family ||=6 unless $AnyEvent::PROTOCOL{ipv4};
218 221
219 $proto ||= "tcp"; 222 $proto ||= "tcp";
220 $type ||= $proto eq "udp" ? Socket::SOCK_DGRAM : Socket::SOCK_STREAM; 223 $type ||= $proto eq "udp" ? Socket::SOCK_DGRAM : Socket::SOCK_STREAM;
221 224
222 my $proton = (getprotobyname $proto)[2] 225 my $proton = (getprotobyname $proto)[2]

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines