ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/eg/lwp
(Generate patch)

Comparing Coro/eg/lwp (file contents):
Revision 1.3 by root, Mon Sep 3 02:50:18 2001 UTC vs.
Revision 1.5 by root, Sun Nov 5 02:18:06 2006 UTC

1#!/usr/bin/perl 1#!/usr/bin/perl
2
3# this hack shows how one can overwrite IO::Socket::INET to provide
4# non-blocking sockets by default. This makes lwp magically
5# non-blocking. I hope.
6
7{
8 # this is all the required magic: we replace the constructor.
9 use Coro::Socket;
10 use IO::Socket::INET;
11 sub IO::Socket::INET::new {
12 shift; new Coro::Socket @_;
13 };
14}
15 2
16use Coro; 3use Coro;
17use Coro::Event; 4use Coro::Event;
5use Coro::LWP; # should be use'd as early as possible
18use LWP::Simple; 6use LWP::Simple;
19 7
20$SIG{PIPE} = 'IGNORE'; 8$SIG{PIPE} = 'IGNORE';
21 9
22async { 10async {
11 print "hi2\n";
12 get "http://www.google.de/";
13 print "ho2\n";
14};
15
16async {
23 print "hi\n"; 17 print "hi\n";
24 get "http://localhost/"; 18 get "http://www.yahoo.com/";
25 print "ho\n"; 19 print "ho\n";
26 20
27}; 21};
28 22
29async { 23loop;
30 print "hi2\n";
31 get "http://localhost/";
32 print "ho2\n";
33};
34 24
35loop;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines