--- AnyEvent-FastPing/README 2009/11/17 21:38:07 1.7 +++ AnyEvent-FastPing/README 2010/04/07 14:13:16 1.8 @@ -101,6 +101,19 @@ (IPv4) or 16 (IPv6) octets length), the payload as passed to "icmp_ping" and the round trip time in seconds. + Example: register a callback which simply dumps the received data. + Since the coderef is created on the fly via sub, it would be hard to + unregister this callback again :) + + AnyEvent::FastPing::register_cb sub { + for (@{$_[0]}) { + printf "%s %d %g\n", + (4 == length $_->[0] ? inet_ntoa $_->[0] : Socket6::inet_ntop (&AF_INET6, $_->[0])), + $_->[2], + $_->[1]; + } + }; + Example: a single ping reply with payload of 1 from "::1" gets passed like this: