lambda sub { context $socket; on_writable sub { print $socket "GET $url HTTP/1.0\r\n\r\n"; my $buf = ''; on_readable sub { my $n = sysread( $socket, $buf, 1024, length($buf)); return "read error:$!" unless defined $n; return $buf unless $n; again; } } }