ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/eg/lwp
Revision: 1.4
Committed: Sun Nov 5 02:01:24 2006 UTC (17 years, 7 months ago) by root
Branch: MAIN
Changes since 1.3: +17 -14 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/usr/bin/perl
2    
3 root 1.4 # this hack shows how one can get LWP to be less blocking.
4 root 1.1
5     {
6 root 1.4 # we replace Socket::inet_aton and CORE::select
7     use Coro::Select; # must come early
8     use Coro::Util;
9 root 1.1 use Coro::Socket;
10     use IO::Socket::INET;
11 root 1.4 use Socket;
12     BEGIN {
13     *Socket::inet_aton = \&Coro::Util::inet_aton;
14     *IO::Socket::INET::new = sub { new Coro::Socket forward_class => @_ };
15     }
16 root 1.1 }
17    
18     use Coro;
19     use Coro::Event;
20     use LWP::Simple;
21    
22 root 1.3 $SIG{PIPE} = 'IGNORE';
23    
24 root 1.1 async {
25 root 1.4 print "hi2\n";
26     get "http://www.google.de/";
27     print "ho2\n";
28     };
29    
30     async {
31 root 1.1 print "hi\n";
32 root 1.4 get "http://www.yahoo.com/";
33 root 1.1 print "ho\n";
34    
35     };
36    
37 root 1.4 loop;
38 root 1.1