Network Programming With Anyevent

  • 2,970 views
Uploaded on

A quick and dirty presentation about network programming using the Perl module AnyEvent

A quick and dirty presentation about network programming using the Perl module AnyEvent

More in: Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,970
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
76
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Network Programming with AnyEvent PtPW’08 - {mailto,xmpp}:melo@simplicidade.org
  • 2. Contenders • POE • Event • Danga::Socket • AnyEvent
  • 3. Overhead 10k servers, 20k sockets, 1% active 15,000 11,250 7,500 3,750 0 create request EV Perl Event Glib POE
  • 4. Overhead 10k servers, 20k sockets 300 225 150 75 0 create request EV Perl Event
  • 5. Overhead 8 servers, 16 sockets 300 225 150 75 0 create request EV Perl Event Glib POE
  • 6. Overhead 8 servers, 16 sockets 90.0 67.5 45.0 22.5 0 create request EV Perl Event Glib
  • 7. AnyEvent • framework for event driven programming • thin layer above several event loops • EV, Event, Gtk, Tk, POE • deals with IO handles (incl. unix domain sockets), timers, signals, processes • thousands of sockets with proper event loop (EV)
  • 8. Watchers and Condvars • AnyEvent has two basic concepts • Watchers • Condvars • Watchers wait for externals events: socket input, timer expiration, child process exits • Condvars are a synchronization primitive
  • 9. IO Watchers • Covers file handles, sockets, unix domain sockets • Deals with buffered reads and writes • Can also deal with “reading lines” or “block of bytes”: callback only when we have everything
  • 10. Timers • Execute callback sometime in the future • Single shot timers only • Common uses: timeouts
  • 11. Condvars • Provide syncronization inside your program • A simple broadcast service • Multiple interested parties • Anybody can trigger it • All the interested parties will be notified
  • 12. Read a line $| = 1; print quot;enter your name> quot;; my $name = <STDIN>;
  • 13. Read a line, take II use AnyEvent; $| = 1; print quot;enter your name> quot;; my $name; my $wait_for_input = AnyEvent->io ( fh => *STDIN, poll => quot;rquot;, cb => sub { $name = <STDIN>; } );
  • 14. Demo • A simple broadcast server • Multiple clients • Broadcasts lines sent by one client to all the others • Code http://github.com/melo/presentations/
  • 15. Thanks!