• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Network Programming With Anyevent
 

Network Programming With Anyevent

on

  • 4,801 views

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

Statistics

Views

Total Views
4,801
Views on SlideShare
4,788
Embed Views
13

Actions

Likes
3
Downloads
76
Comments
0

1 Embed 13

http://www.slideshare.net 13

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Network Programming With Anyevent Network Programming With Anyevent Presentation Transcript

    • Network Programming with AnyEvent PtPW’08 - {mailto,xmpp}:melo@simplicidade.org
    • Contenders • POE • Event • Danga::Socket • AnyEvent
    • Overhead 10k servers, 20k sockets, 1% active 15,000 11,250 7,500 3,750 0 create request EV Perl Event Glib POE
    • Overhead 10k servers, 20k sockets 300 225 150 75 0 create request EV Perl Event
    • Overhead 8 servers, 16 sockets 300 225 150 75 0 create request EV Perl Event Glib POE
    • Overhead 8 servers, 16 sockets 90.0 67.5 45.0 22.5 0 create request EV Perl Event Glib
    • 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)
    • 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
    • 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
    • Timers • Execute callback sometime in the future • Single shot timers only • Common uses: timeouts
    • Condvars • Provide syncronization inside your program • A simple broadcast service • Multiple interested parties • Anybody can trigger it • All the interested parties will be notified
    • Read a line $| = 1; print quot;enter your name> quot;; my $name = <STDIN>;
    • 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>; } );
    • Demo • A simple broadcast server • Multiple clients • Broadcasts lines sent by one client to all the others • Code http://github.com/melo/presentations/
    • Thanks!