ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/eg/lwp
Revision: 1.3
Committed: Mon Sep 3 02:50:18 2001 UTC (22 years, 10 months ago) by root
Branch: MAIN
CVS Tags: rel-2_0, rel-2_1, rel-1_1, rel-1_0, rel-1_9, rel-1_2, rel-1_5, rel-1_4, rel-1_7, rel-1_6, rel-1_31
Changes since 1.2: +2 -0 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/usr/bin/perl
2    
3 root 1.2 # 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 root 1.1
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    
16     use Coro;
17     use Coro::Event;
18     use LWP::Simple;
19    
20 root 1.3 $SIG{PIPE} = 'IGNORE';
21    
22 root 1.1 async {
23     print "hi\n";
24     get "http://localhost/";
25     print "ho\n";
26    
27     };
28    
29     async {
30     print "hi2\n";
31     get "http://localhost/";
32     print "ho2\n";
33     };
34    
35     loop;