use warnings; use strict; use POE qw(Component::Server::TCP); POE::Component::Server::TCP->new( Port => 12345, ClientFilter => "POE::Filter::Stream", ClientConnected => sub { print "got a connection from $_[HEAP]{remote_ip}\n"; my $buffer; open FILE, "file" or die "Couldn't open file: $!"; while (){ $buffer .= $_; } close FILE; $_[HEAP]{client}->put($buffer); }, ClientInput => sub { my ($client_input, $heap) = @_[ARG0, HEAP]; push @{ $heap->{banner_buffer} }, $client_input; }, ClientDisconnected => sub { print "client from $_[HEAP]{remote_ip} disconnected\n"; }, InlineStates => { input_display=>sub{ my ($client_input, $heap) = @_[ARG0, HEAP]; foreach ( @{ $heap->{banner_buffer} } ) { print "|| $_"; } } }, ); POE::Kernel->run; exit;