GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  NET::ANALYSIS::LISTENER::EXAMPLE1 (3)

.ds Aq ’

NAME

Net::Analysis::Listener::Example1 - emit/receive custom events

CONTENTS

SYNOPSIS



 package Net::Analysis::Listener::Example1;

 use strict;
 use warnings;
 use base qw(Net::Analysis::Listener::Base);

 sub tcp_monologue {
     my ($self, $args) = @_;
     my ($mono) = $args->{monologue}; # isa Net::Analysis::TCPMonologue

     my $t = $mono->t_elapsed()->as_number();
     my $l = $mono->length();

     $self->emit(name => example_bandwidth_measurement_event,
                 args => { kb_sec => ($t) ? $l/($t*1024) : 0 }
                );
 }

 sub example_bandwidth_measurement_event {
     my ($self, $args) = @_;

     printf "Bandwidth: %10.2f KB/sec\n", $args->{kb_sec};
 }

 1;



You can invoke this example on a TCP capture file from the command line, as follows:



 $ perl -MNet::Analysis -e main Example1 t/t1_google.tcp



DESCRIPTION

This example shows how to emit your own custom events, and also how to listen to them. This particular example has example_bandwidth_measurement_event in the same Listener.pm file, but you could easily put it in another Listener.pm if you wanted - just remember to tell the dispatcher about both of them.

SEE ALSO

Net::Analysis.

AUTHOR

Adam B. Worrall, <worrall@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2004 by Adam B. Worrall

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 NET::ANALYSIS::LISTENER::EXAMPLE1 (3) 2010-03-24

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.