AnyEvent::Socket:: => Coro::Handle
Aleksandar Lazic
al-anyevent at none.at
Mon Sep 5 22:18:42 CEST 2011
Dear Marc,
I try to learn coro and anyevent base on your httpd.pl in Coro/myhttpd
directory. I have read the README ;-)
I have read that on
http://pod.tst.eu/http://cvs.schmorp.de/Coro/Coro/Socket.pm
###
Therefore it is not recommended to use Coro::Socket in new
code. Instead, use AnyEvent::Socket and Coro::Handle, e.g.:
###
that Coro::Socket is deprecated.
I have tried now the following changes.
###
tcp_server $::SERVER_HOST, $::SERVER_PORT, sub {
my ($fh, $host, $port) = @_;
async_pool {
handle_server($fh,$host);
}
};
###
instead of
####
my $http_port = new Coro::Socket
LocalAddr => $::SERVER_HOST,
LocalPort => $::SERVER_PORT,
ReuseAddr => 1,
Listen => 50,
or die "unable to start server";
listen_on $http_port;
####
and in the conn::handle {
my $self = shift;
my $AnyEvSock_fh = $self->{fh} or die unless $self->{fh};
my $fh = new_from_fh Coro::Handle $AnyEvSock_fh;
my $host;
$fh->timeout($::REQ_TIMEOUT);
....
####
I get the follwoing error:
2011-09-05 20:15:09: Can't call method "timeout" on an undefined value
at httpd.pl line 314.
This is the output of Dumper(@_) in sub handle
<<<<<<<<<<<<<<<handle>>>>>>>>>>>>>>>>
$VAR1 = bless( {
'remote_addr' => '127.0.0.1',
'remote_id' => '127.0.0.1',
'time' => '1315253709.00074',
'fh' => \*{'AnyEvent::Socket::'}
}, 'conn' );
###
Please can you help me to understand how to go the right way to be able
to set the timeout.
Many thanks.
Aleks
More information about the anyevent
mailing list