use IO::Socket; use Net::hostent; # for OO version of gethostbyaddr use POE; $PORT = 5039; # pick something not in use $sock = IO::Socket::INET->new( Proto => 'tcp', LocalPort => $PORT, Listen => 1, Reuse => 1); die "can't setup server" unless $sock; print "[Server $0 accepting clients]\n"; $command = $sock->accept(); while (1) { while (<$command>) { POE::Session->create( inline_states => { _start => sub { qx(/etc/init.d/asterisk start); } }, ); $poe_kernel->run(); } sleep(1); }