#/usr/local/bin/perl require "easy-serv.pl"; # loading the library &esv'register_serv(SERVER, 2345); # make a server socket on port 7999 &esv'run_serv(); # dispatching (never returns) sub serv_body { # Users must supply this routine. # $_[0] : request data sent from a client # $_[1] : socket name corresponding to the current client print "client sock name=" . $_[1] . "\n"; if ($_[0] eq "who") { $reply = `who`; } elsif ($_[0] eq "ps") { $reply = `ps`; } elsif ($_[0] eq "kill") { &cleanup_serv(); } else { $reply = "who : who is on this host\\n" . "ps : show process\\n" . "kill : kill server\\n" . "help : show this message\\n"; } return $reply; # This value is sent back to the current client }