Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: AnyEvent::Handle::UDP -- can't get it to receive?

by creeble (Sexton)
on Apr 27, 2012 at 00:21 UTC ( [id://967493]=note: print w/replies, xml ) Need Help??


in reply to Re^2: AnyEvent::Handle::UDP -- can't get it to receive?
in thread AnyEvent::Handle::UDP -- can't get it to receive?

Ug, yeah, whoops, that was me (creeble). Forgot to log in.
  • Comment on Re^3: AnyEvent::Handle::UDP -- can't get it to receive?

Replies are listed 'Best First'.
Re^4: AnyEvent::Handle::UDP -- can't get it to receive?
by Neighbour (Friar) on May 03, 2012 at 08:17 UTC
    Hmmno thanks. I already have a job, and though it has its ups and downs, I'm not looking for another :).
    You're still free to keep asking questions to the monks in general though.

    Edit: Cleaned up code and perltidy'd it. There seems to be a bug in Net::DNS::Packet where, if you remove the debug-flag when creating a new packet object from raw data, the answer section doesn't get decoded.
    use strict; use warnings; use AnyEvent::Handle::UDP; use Socket; use Net::DNS::Packet; use Data::Dump; my $target_host = shift; if (!defined $target_host) { print ("Usage: $0 hostname\n"); exit 1; } my $d = Net::DNS::Packet->new($target_host, "PTR"); my $cv_recv = AnyEvent->condvar; my $t = AnyEvent::Handle::UDP->new( timeout => 3, on_timeout => sub { print STDERR "Nothing happened within the specified timeout ti +meframe...\n"; }, on_error => sub { print STDERR "An error has occurred:"; Data::Dump::dd(@_); }, on_recv => sub { my ($buf, $handle) = @_; my ($res, $err) = Net::DNS::Packet->new(\$buf,1); if ($err) { print STDERR $err . "\n"; } else { Data::Dump::dd($res); } $cv_recv->send; }, ); $t->bind_to(['0.0.0.0', 0]); my $cv_send = $t->push_send($d->data, pack_sockaddr_in(53, Socket::ine +t_aton('IP_OF_DNS-SERVER_HERE'))); print ("Waiting for data to be sent..."); $cv_send->recv; print ("[OK]\n"); print ("Waiting for data to arrive..."); $cv_recv->recv; print ("[OK]\n");

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://967493]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-19 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found