Dear all.

Anyone using NetServer::Generic?
I've just bigun to use, and have a question.
I sent this question to author recently without reply.

By the following code that I inserted STDERR msgs, the script ends
after recieving "bye" from clients,
badly ends by "exit".

I hope "return" will end this connection, and
"quit()" will end the whole script.

Can you guess what is wrong?

Or I must code like?
--------------------------------------
for (;;) {
  $foo->run();
  if (..SOME_CONDITION..) { last }
}
--------------------------------------

My env is:
Solaris 8
Perl 5.6.1 from sun.freeare.com by pkgadd
NetServer-Generic-1.03 (was installed by gcc as good)

--
Best.
Hirosi Taguti
[EMAIL PROTECTED]


------------------------------------------------------- log for quit
22:14:55 /usr/cocobiz/prog $ aHTTP2.pl
hostname: itgdev6
=====> Starting server
server_cb entered...
server_cb entered...
server_cb, bye has come!
=====> Ending server
22:15:18 /usr/cocobiz/prog $ server_cb, bye has come!

22:16:17 /usr/cocobiz/prog $
-------------------------------------------------------

------------------------------------------------------- log for exit
22:26:27 /usr/cocobiz/prog $ aHTTP2.pl
hostname: itgdev6
=====> Starting server
server_cb entered...
end(software term signal)
22:26:38 /usr/cocobiz/prog $
-------------------------------------------------------

I added,
++$NetServer::Debug;

This script ends by "bye" calls.
-------------------------------------------------------
22:49:52 /usr/cocobiz/prog $ aHTTP2.pl
[NetServer::Generic]
hostname: itgdev6
=====> Starting server
run() ...
22358 : Wed Jan 16 22:49:58 2002 : incoming connection from 172.27.11.245
./aHTTP2.pl:22358: request from h-taguchi.secom-sis.co.jp 172.27.11.245
22358 : Wed Jan 16 22:49:58 2002 : processing connection
server_cb entered...
./aHTTP2.pl:22357: forked 22358
22359 : Wed Jan 16 22:50:05 2002 : incoming connection from 172.27.11.245
./aHTTP2.pl:22359: request from h-taguchi.secom-sis.co.jp 172.27.11.245
22359 : Wed Jan 16 22:50:05 2002 : processing connection
server_cb entered...
./aHTTP2.pl:22357: forked 22359
server_cb, bye has come!
./aHTTP2.pl:22359: end of transaction
22359 : Wed Jan 16 22:50:17 2002 : took 11.446392 seconds
=====> Ending server
22:50:17 /usr/cocobiz/prog $
-------------------------------------------------------

-------------------------------------------------------
itgdev6% ps -ef |grep HTT
  taguti 22361 21962  0 22:50:11 pts/7    0:00 grep HTT
  taguti 22357 22321  1 22:49:53 pts/9    0:00 /usr/local/bin/perl ./aHTTP2.pl
  taguti 22358 22357  0 22:49:58 pts/9    0:00 /usr/local/bin/perl ./aHTTP2.pl
  taguti 22359 22357  0 22:50:05 pts/9    0:00 /usr/local/bin/perl ./aHTTP2.pl
itgdev6% ps -ef |grep HTT
  taguti 22358     1  0 22:49:58 pts/9    0:00 /usr/local/bin/perl ./aHTTP2.pl
  taguti 22363 21962  0 22:50:40 pts/7    0:00 grep HTT
itgdev6% ps -ef |grep HTT
  taguti 22365 21962  0 22:51:11 pts/7    0:00 grep HTT
itgdev6%
-------------------------------------------------------



------------------------------------------------------- aHTTP2.pl
#!/usr/local/bin/perl
use NetServer::Generic;
my $server_cb = sub  {
                       my ($s) = shift ;
                       print STDERR "server_cb entered...\n";
                       print STDOUT "Echo server: type bye to quit, exit ",
                                    "to kill the server.\n\n" ;
                       while (defined ($tmp = <STDIN>)) {
                           if ($tmp =~ /^bye/i) {
                               print STDERR "server_cb, bye has come!\n";
                               return;
                           }
                           $s->quit() if ($tmp =~ /^exit/i);
                           print STDOUT "You said:>$tmp\n";
                       }
                       print STDERR "'while' loop ended.\n";
                     };
my ($foo) = new NetServer::Generic;
print STDERR "hostname: itgdev6\n";
$foo->hostname("itgdev6");
$foo->port(9000);
$foo->callback($server_cb);
$foo->mode("forking");
print "=====> Starting server\n";
$foo->run();
print "=====> Ending server\n";
#####
-------------------------------------------------------
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users

Reply via email to