Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added AnyEvent script

  • Loading branch information...
commit e6d5f985d188006da54bfb99ca8599fa253a1a42 1 parent a6733a5
@tokuhirom authored
Showing with 28 additions and 0 deletions.
  1. +28 −0 echo-ae.pl
View
28 echo-ae.pl
@@ -0,0 +1,28 @@
+use strict;
+use warnings;
+use AE;
+use Getopt::Long;
+use AnyEvent::Socket;
+use AnyEvent::Handle;
+
+my $concurrent = 10;
+my $port = 9010;
+GetOptions(
+ 'concurrent=s' => \$concurrent,
+ 'port=i' => \$port,
+);
+
+print "coro: http://localhost:$port/\n";
+print "concurrency: $concurrent\n";
+tcp_server undef, $port, sub {
+ my ($fh, $host, $port) = @_;
+ my $sock = AnyEvent::Handle->new(fh => $fh);
+ $sock->on_read(
+ sub {
+ $sock->push_write($_[0]->{rbuf});
+ $_[0]->{rbuf} = '';
+ }
+ );
+};
+AE::cv->recv;
+
Please sign in to comment.
Something went wrong with that request. Please try again.