--- Coro/eg/lwp 2001/09/03 02:50:18 1.3 +++ Coro/eg/lwp 2007/04/14 15:06:06 1.6 @@ -1,35 +1,25 @@ #!/usr/bin/perl -# this hack shows how one can overwrite IO::Socket::INET to provide -# non-blocking sockets by default. This makes lwp magically -# non-blocking. I hope. - -{ - # this is all the required magic: we replace the constructor. - use Coro::Socket; - use IO::Socket::INET; - sub IO::Socket::INET::new { - shift; new Coro::Socket @_; - }; -} - use Coro; use Coro::Event; +use Coro::LWP; # should be use'd as early as possible use LWP::Simple; $SIG{PIPE} = 'IGNORE'; -async { - print "hi\n"; - get "http://localhost/"; - print "ho\n"; +my @pids; +push @pid, async { + print "starting to fetch http://www.google.de/\n"; + get "http://www.google.de/"; + print "fetched http://www.google.de/\n"; }; -async { - print "hi2\n"; - get "http://localhost/"; - print "ho2\n"; +push @pid, async { + print "starting to fetch http://www.yahoo.com/\n"; + get "http://www.yahoo.com/"; + print "fetched http://www.yahoo.com/\n"; }; -loop; +$_->join for @pid; +