in reply to Re: Win32::Daemon + socket->accept: service cannot be stopped
in thread Win32::Daemon + socket->accept: service cannot be stopped [SOLVED]
... elsif( SERVICE_RUNNING == $State ) { our $sock = new IO::Socket::INET(LocalPort => MYPORT, Reuse => 1, Listen => 5 ) or LOGDIE "can't create local socket: $@\n"; INFO "Accepting connections on Port ", MYPORT, "..."; our $client; $SIG{'CHLD'} = sub { wait(); }; # No Zombies my $pid = fork(); if ($pid == 0) { # Child while ( 1 == 1) { if ( $client = $sock->accept() ) { INFO "Connection from ", $client->peerhost(), ":", $cl +ient->peerport(); while (<$client>) { unless ($_ =~ /^[\w.-_\s]+$/) { print $client "Invalid Input!. Type [h]elp for + help\n"; next; } chomp; $_ =~ s/\r$//; DEBUG "Got command: $_"; my $output = get_output($_); print $client $output; } INFO "Client " . $client->peerhost() . " has disconnec +ted."; } } } else { while ( SERVICE_STOP_PENDING != Win32::Daemon::State() ) { sleep 5; } #### We are done so close down... ### Win32::Daemon::State( SERVICE_STOPPED ); Win32::Daemon::StopService(); INFO "Need to go, bye"; kill(9, $pid); exit; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Win32::Daemon + socket->accept: service cannot be stopped
by Jenda (Abbot) on Jun 24, 2005 at 14:18 UTC | |
by svenXY (Deacon) on Jun 27, 2005 at 08:45 UTC |