… | |
… | |
57 | tcp_server |
57 | tcp_server |
58 | tcp_connect |
58 | tcp_connect |
59 | ); |
59 | ); |
60 | |
60 | |
61 | our $VERSION = $AnyEvent::VERSION; |
61 | our $VERSION = $AnyEvent::VERSION; |
62 | |
|
|
63 | # used in cases where we may return immediately but want the |
|
|
64 | # caller to do stuff first |
|
|
65 | sub _postpone { |
|
|
66 | my ($cb, @args) = (@_, $!); |
|
|
67 | |
|
|
68 | my $w; $w = AE::timer 0, 0, sub { |
|
|
69 | undef $w; |
|
|
70 | $! = pop @args; |
|
|
71 | $cb->(@args); |
|
|
72 | }; |
|
|
73 | } |
|
|
74 | |
62 | |
75 | =item $ipn = parse_ipv4 $dotted_quad |
63 | =item $ipn = parse_ipv4 $dotted_quad |
76 | |
64 | |
77 | Tries to parse the given dotted quad IPv4 address and return it in |
65 | Tries to parse the given dotted quad IPv4 address and return it in |
78 | octet form (or undef when it isn't in a parsable format). Supports all |
66 | octet form (or undef when it isn't in a parsable format). Supports all |
… | |
… | |
896 | |
884 | |
897 | $state{next} = sub { |
885 | $state{next} = sub { |
898 | return unless exists $state{fh}; |
886 | return unless exists $state{fh}; |
899 | |
887 | |
900 | my $target = shift @target |
888 | my $target = shift @target |
901 | or return _postpone sub { |
889 | or return AnyEvent::postpone { |
902 | return unless exists $state{fh}; |
890 | return unless exists $state{fh}; |
903 | %state = (); |
891 | %state = (); |
904 | $connect->(); |
892 | $connect->(); |
905 | }; |
893 | }; |
906 | |
894 | |