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

Comparing AnyEvent/lib/AnyEvent/Util.pm (file contents):
Revision 1.5 by root, Sun Apr 27 20:17:46 2008 UTC vs.
Revision 1.6 by root, Fri May 2 15:36:10 2008 UTC

104sub inet_aton { 104sub inet_aton {
105 my ($name, $cb) = @_; 105 my ($name, $cb) = @_;
106 106
107 if (&dotted_quad) { 107 if (&dotted_quad) {
108 $cb->(Socket::inet_aton $name); 108 $cb->(Socket::inet_aton $name);
109 } elsif ($name eq "localhost") { # rfc2606 et al.
110 $cb->(v127.0.0.1);
109 } elsif (&has_ev_adns) { 111 } elsif (&has_ev_adns) {
110 EV::ADNS::submit ($name, &EV::ADNS::r_addr, 0, sub { 112 EV::ADNS::submit ($name, &EV::ADNS::r_addr, 0, sub {
111 my (undef, undef, @a) = @_; 113 my (undef, undef, @a) = @_;
112 $cb->(@a ? Socket::inet_aton $a[0] : undef); 114 $cb->(@a ? Socket::inet_aton $a[0] : undef);
113 }); 115 });
114 } else { 116 } else {
115 _do_asy $cb, sub { Socket::inet_aton $_[0] }, @_; 117 _do_asy $cb, sub { Socket::inet_aton $_[0] }, @_;
118 }
119}
120
121=item AnyEvent::Util::fh_nonblocking $fh, $nonblocking
122
123Sets the blocking state of the given filehandle (true == nonblocking,
124false == blocking). Uses fcntl on anything sensible and ioctl FIONBIO on
125broken (i.e. windows) platforms.
126
127=cut
128
129sub fh_nonblocking($$) {
130 my ($fh, $nb) = @_;
131
132 require Fcntl;
133
134 if ($^O eq "MSWin32") {
135 $nb = (! ! $nb) + 0;
136 ioctl $fh, 0x8004667e, \$nb; # FIONBIO
137 } else {
138 fcntl $fh, &Fcntl::F_SETFL, $nb ? &Fcntl::O_NONBLOCK : 0;
116 } 139 }
117} 140}
118 141
1191; 1421;
120 143

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines