1 |
sub POE::Kernel::ASSERT_DEFAULT () { 1 } |
2 |
sub POE::Kernel::TRACE_DEFAULT () { 1 } |
3 |
|
4 |
use POE qw(Component::Server::TCP); |
5 |
|
6 |
$bind_port = 8000; |
7 |
$bind_address = '127.0.0.1'; |
8 |
|
9 |
# First form just accepts connections. |
10 |
|
11 |
POE::Component::Server::TCP->new |
12 |
( Port => $bind_port, |
13 |
Address => $bind_address, # Optional. |
14 |
Acceptor => \&accept_handler, |
15 |
Error => \&error_handler, # Optional. |
16 |
); |
17 |
|
18 |
|
19 |
|
20 |
sub accept_handler { |
21 |
my ($socket, $remote_address, $remote_port) = @_[ARG0, ARG1, ARG2]; |
22 |
print "accept", "\n"; |
23 |
} |
24 |
|
25 |
sub error_handler { |
26 |
my ($syscall_name, $error_number, $error_string) = @_[ARG0, ARG1, ARG2]; |
27 |
print "error", "\n"; |
28 |
} |
29 |
|
30 |
$poe_kernel->run(); |
31 |
|