mobiusinversion has asked for the wisdom of the Perl Monks concerning the following question:
This doesn't work and also if I telnet to localhost:44244 I get this:#!/usr/bin/env perl use AnyEvent; use AnyEvent::Handle; use AnyEvent::Socket; my $cv = AnyEvent->condvar; my $host = '127.0.0.1'; my $port = 44244; tcp_server($host, $port, sub { my($fh) = @_; my $cv = AnyEvent->condvar; my $handle; $handle = AnyEvent::Handle->new( fh => $fh, poll => "r", on_read => sub { my($self) = @_; print "Received: " . $self->rbuf . "\n"; $cv->send; } ); $cv->recv; }); print "Listening on $host\n"; $cv->wait;
I think if I understand how to make a mini, single threaded server that simply prints out whatever its given and then waits for more input, I could take it a lot further from there. Any ideas?EV: error in callback (ignoring): AnyEvent::CondVar: recursive blockin +g wait attempted at server.pl line 29.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Creating A Single Threaded Server with AnyEvent
by Tanktalus (Canon) on Nov 07, 2012 at 00:31 UTC | |
|
Re: Creating A Single Threaded Server with AnyEvent
by Kenosis (Priest) on Nov 06, 2012 at 23:12 UTC | |
| |
|
Re: Creating A Single Threaded Server with AnyEvent
by james2vegas (Chaplain) on Nov 07, 2012 at 08:57 UTC | |
|
Re: Creating A Single Threaded Server with AnyEvent
by rcaputo (Chaplain) on Nov 06, 2012 at 23:03 UTC | |
by mobiusinversion (Beadle) on Nov 06, 2012 at 23:15 UTC | |
by rcaputo (Chaplain) on Nov 06, 2012 at 23:27 UTC | |
|
Re: Creating A Single Threaded Server with AnyEvent
by zentara (Cardinal) on Nov 08, 2012 at 11:09 UTC |