Your SlideShare is downloading. ×
0
Network Programming With Anyevent
Network Programming With Anyevent
Network Programming With Anyevent
Network Programming With Anyevent
Network Programming With Anyevent
Network Programming With Anyevent
Network Programming With Anyevent
Network Programming With Anyevent
Network Programming With Anyevent
Network Programming With Anyevent
Network Programming With Anyevent
Network Programming With Anyevent
Network Programming With Anyevent
Network Programming With Anyevent
Network Programming With Anyevent
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Network Programming With Anyevent

3,159

Published 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

Published in: Technology, Business
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,159
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
77
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!

×