1 | #!/usr/bin/perl |
1 | #!/usr/bin/perl |
2 | |
2 | |
3 | # this hack shows how one can overwrite |
3 | # this hack shows how one can overwrite IO::Socket::INET to provide |
4 | # IO::Socket::INET to provide non-blocking sockets by default. |
4 | # non-blocking sockets by default. This makes lwp magically |
5 | # this makes lwp magically non-blocking. I hope. |
5 | # non-blocking. I hope. |
6 | |
6 | |
7 | { |
7 | { |
8 | # this is all the required magic: we replace the constructor. |
8 | # this is all the required magic: we replace the constructor. |
9 | use Coro::Socket; |
9 | use Coro::Socket; |
10 | use IO::Socket::INET; |
10 | use IO::Socket::INET; |
… | |
… | |
14 | } |
14 | } |
15 | |
15 | |
16 | use Coro; |
16 | use Coro; |
17 | use Coro::Event; |
17 | use Coro::Event; |
18 | use LWP::Simple; |
18 | use LWP::Simple; |
|
|
19 | |
|
|
20 | $SIG{PIPE} = 'IGNORE'; |
19 | |
21 | |
20 | async { |
22 | async { |
21 | print "hi\n"; |
23 | print "hi\n"; |
22 | get "http://localhost/"; |
24 | get "http://localhost/"; |
23 | print "ho\n"; |
25 | print "ho\n"; |