Difference between revisions of "Perl POE"
From Teknologisk videncenter
m (→Links) |
m |
||
Line 1: | Line 1: | ||
− | + | =POE - portable multitasking and networking framework for Perl= | |
− | == A simple multitasking TCP Server | + | == A simple multitasking TCP Server == |
<source lang="perl"> | <source lang="perl"> | ||
#!/usr/bin/perl | #!/usr/bin/perl |
Revision as of 17:39, 15 March 2009
POE - portable multitasking and networking framework for Perl
A simple multitasking TCP Server
#!/usr/bin/perl
use warnings;
use strict;
use POE qw(Component::Server::TCP);
POE::Component::Server::TCP->new(
Port => 12345,
ClientConnected => sub {
print "got a connection from $_[HEAP]{remote_ip}\n";
$_[HEAP]{client}->put("Smile from the server.");
},
ClientInput => sub {
my $client_input = $_[ARG0];
$client_input =~ tr[a-zA-Z][A-Za-z];
$_[HEAP]{client}->put($client_input);
},
ClientDisconnected => sub {
print "client from $_[HEAP]{remote_ip} disconnected\n";
},
);
POE::Kernel->run;
exit;