async { while (my $host = $input->get()) # note that putting false will cause this to exit - probably a good thing { print "got $host\n"; async_pool { tcp_connect $host, 65432, Coro::rouse_cb; my ($fh) = Coro::rouse_wait; return unless $fh; print "got socket for $host\n"; my $coro = $Coro::current; my $t = AnyEvent->timer( after => 10, cb => sub { print "$host: timed out\n"; $coro->cancel } ); # do stuff? } # async pool } }