Event::Lib::UDPPump

Event::Lib::UDPPump is an Event::Lib event type for high performance UDP applications.
Download

Event::Lib::UDPPump Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Clayton O'Neill
  • Publisher web site:
  • http://search.cpan.org/~cmo/Event-Lib-UDPPump-0.01/lib/Event/Lib/UDPPump.pm

Event::Lib::UDPPump Tags


Event::Lib::UDPPump Description

Event::Lib::UDPPump is an Event::Lib event type for high performance UDP applications. Event::Lib::UDPPump is an Event::Lib event type for high performance UDP applications.SYNOPSIS use Event::Lib::UDPPump; use IO::Socket::INET; my $numchildren = 10; my $s = IO::Socket::INET->new(Proto => 'udp', LocalPort => 5000); fork() foreach (1..($numchildren - 1)); my $pump = udppump_new($s, &callback, @args); $pump->add(); event_mainloop(); sub callback { my ($results_href, @args) = @_; # Process results here. }This module is intended for people writing high performance UDP applications. It is an extension of the Event::Lib module, and can provide better performance in several circumstances.When a UDPPump event is registered for a UDP socket, a pthreads thread is created in the background. All this thread does is block in recvfrom waiting for a packet to be received on the socket. When that happens, it will then pass a packet over to the main thread which will call the callback you have registered. This will be more efficent specifically in the case when you have several processes or threads all processing data on the same UDP port. This avoids the problem with multiple processes all blocking in select (or poll, etc) waiting for traffic on the same socket, and then all waiting up and trying to read from the socket at the same time when new data arrives.This can make it easier to implement daemons where each request may require significant processing. This is because while your callback is running, the recvfrom thread will be blocking waiting for you to complete. This means that you can run a number of child processes as workers, and as long as you have a few of them waiting in recvfrom then response times will not suffer.The other primary benefit is that it can allow you to take advantage of multi-processor/multi-core servers without having to resort to using threads. This is the primary reason that this module was implemented. Requirements: · Perl


Event::Lib::UDPPump Related Software