I have some scripts which must be fast as possible (used as mpd5 up/down scripts).
Have the idea: lets this script send arguments to some tcp server and finish work, and then the server works hard and long.
This is my test server script with Net::Server :
use Net::Server::PreForkSimple;
use base "Net::Server::PreForkSimple";
sub process_request {
my $self=shift;
my $a=<STDIN>;
close STDIN; close STDOUT; #trying to disconect client here
$self->log(1,"start $a");
sleep 50;
$self->log(1,"finish $a");
}
__PACKAGE__->run(port => 2000);
Problem is : i dont know how to disconect client on line after $a=.
Client script waiting all this “sleep 50”.
I am trying close STD* but its doesnt help.
Also I cant locate any close or disconect method in docs of this Net::Server.
Can anyone point me to right direction?
UPD:
close($self->{server}->{client});
doesnt work too.
I test this by
echo test | nc 127.0.0.1 2000
and this command is working 50 sec.
But i want nc closed immediately after send “test”.
After i posted this Q on rt.cpan.org , i get a answer:
right code with fast disconnect is: