Hi,

I want to create a POE server that doesn't block my terminal when I start
it.  I did it with a fork but I haven't seen anyone do it this way so I
figure I'm missing something in POE to do it.

How am I supposed to build a server that when I start it, I get my prompt
back?

Thanks
Jay

So far I have:

#!/usr/bin/perl -w

use warnings;
use strict;
$|++;

use POE qw(Component::Server::TCP);

if (!defined(my $child_pid = fork())) {
    die "cannot fork $!\n";
}
elsif ($child_pid) {
    print "parent $child_pid\n";
}
else {
    print "starting server\n";

    POE::Component::Server::TCP->new(
    Port        => 12345,
    ClientInput => \&client_input,
    Alias => "quoted",
    );

    POE::Kernel->run();
    exit;
}

sub client_input {
    my ($heap, $input) = @_[HEAP, ARG0];
    print $input,"\n";
    $heap->{client}->put($input);
}



Reply via email to