home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / perl5 / Net / Server.pod < prev   
Encoding:
Text File  |  2007-07-25  |  48.1 KB  |  1,472 lines

  1. =head1 NAME
  2.  
  3. Net::Server - Extensible, general Perl server engine
  4.  
  5. =head1 SYNOPSIS
  6.  
  7.     #!/usr/bin/perl -w -T
  8.     package MyPackage;
  9.  
  10.     use base qw(Net::Server);
  11.  
  12.     sub process_request {
  13.         my $self = shift;
  14.         while (<STDIN>) {
  15.             s/\r?\n$//;
  16.             print "You said '$_'\r\n"; # basic echo
  17.             last if /quit/i;
  18.         }
  19.     }
  20.  
  21.     MyPackage->run(port => 160);
  22.  
  23. =head1 FEATURES
  24.  
  25.  * Single Server Mode
  26.  * Inetd Server Mode
  27.  * Preforking Simple Mode (PreForkSimple)
  28.  * Preforking Managed Mode (PreFork)
  29.  * Forking Mode
  30.  * Multiplexing Mode using a single process
  31.  * Multi port accepts on Single, Preforking, and Forking modes
  32.  * Simultaneous accept/recv on tcp, udp, and unix sockets
  33.  * Safe signal handling in Fork/PreFork avoids perl signal trouble
  34.  * User customizable hooks
  35.  * Chroot ability after bind
  36.  * Change of user and group after bind
  37.  * Basic allow/deny access control
  38.  * Customized logging (choose Syslog, log_file, or STDERR)
  39.  * HUP able server (clean restarts via sig HUP)
  40.  * Dequeue ability in all Fork and PreFork modes.
  41.  * Taint clean
  42.  * Written in Perl
  43.  * Protection against buffer overflow
  44.  * Clean process flow
  45.  * Extensibility
  46.  
  47. =head1 DESCRIPTION
  48.  
  49. C<Net::Server> is an extensible, generic Perl server engine.
  50. C<Net::Server> combines the good properties from
  51. C<Net::Daemon> (0.34), C<NetServer::Generic> (1.03), and
  52. C<Net::FTPServer> (1.0), and also from various concepts in
  53. the Apache Webserver.
  54.  
  55. C<Net::Server> attempts to be a generic server as in
  56. C<Net::Daemon> and C<NetServer::Generic>.  It includes with
  57. it the ability to run as an inetd process
  58. (C<Net::Server::INET>), a single connection server
  59. (C<Net::Server> or C<Net::Server::Single>), a forking server
  60. (C<Net::Server::Fork>), a preforking server which maintains
  61. a constant number of preforked children (C<Net::Server::PreForkSimple>),
  62. or as a managed preforking server which maintains the number
  63. of children based on server load (C<Net::Server::PreFork>).
  64. In all but the inetd type, the server provides the ability to
  65. connect to one or to multiple server ports.
  66.  
  67. C<Net::Server> uses ideologies of C<Net::FTPServer> in order
  68. to provide extensibility.  The additional server types are
  69. made possible via "personalities" or sub classes of the
  70. C<Net::Server>.  By moving the multiple types of servers out of
  71. the main C<Net::Server> class, the C<Net::Server> concept is
  72. easily extended to other types (in the near future, we would
  73. like to add a "Thread" personality).
  74.  
  75. C<Net::Server> borrows several concepts from the Apache
  76. Webserver.  C<Net::Server> uses "hooks" to allow custom
  77. servers such as SMTP, HTTP, POP3, etc. to be layered over
  78. the base C<Net::Server> class.  In addition the
  79. C<Net::Server::PreFork> class borrows concepts of
  80. min_start_servers, max_servers, and min_waiting servers.
  81. C<Net::Server::PreFork> also uses the concept of an flock
  82. serialized accept when accepting on multiple ports (PreFork
  83. can choose between flock, IPC::Semaphore, and pipe to control
  84. serialization).
  85.  
  86. =head1 PERSONALITIES
  87.  
  88. C<Net::Server> is built around a common class (Net::Server)
  89. and is extended using sub classes, or C<personalities>.
  90. Each personality inherits, overrides, or enhances the base
  91. methods of the base class.
  92.  
  93. Included with the Net::Server package are several basic
  94. personalities, each of which has their own use.
  95.  
  96. =over 4
  97.  
  98. =item Fork
  99.  
  100. Found in the module Net/Server/Fork.pm (see
  101. L<Net::Server::Fork>).  This server binds to one or more
  102. ports and then waits for a connection.  When a client
  103. request is received, the parent forks a child, which then
  104. handles the client and exits.  This is good for moderately
  105. hit services.
  106.  
  107. =item INET
  108.  
  109. Found in the module Net/Server/INET.pm (see
  110. L<Net::Server::INET>).  This server is designed to be used
  111. with inetd.  The C<pre_bind>, C<bind>, C<accept>, and
  112. C<post_accept> are all overridden as these services are
  113. taken care of by the INET daemon.
  114.  
  115. =item MultiType
  116.  
  117. Found in the module Net/Server/MultiType.pm (see
  118. L<Net::Server::MultiType>).  This server has no server
  119. functionality of its own.  It is designed for servers which
  120. need a simple way to easily switch between different
  121. personalities.  Multiple C<server_type> parameters may be
  122. given and Net::Server::MultiType will cycle through until it
  123. finds a class that it can use.
  124.  
  125. =item Multiplex
  126.  
  127. Found in the module Net/Server/Multiplex.pm (see
  128. L<Net::Server::Multiplex>).  This server binds to one or more
  129. ports.  It uses IO::Multiplex to multiplex between waiting
  130. for new connections and waiting for input on currently
  131. established connections.  This personality is designed to
  132. run as one process without forking.  The C<process_request>
  133. method is never used but the C<mux_input> callback is used
  134. instead (see also L<IO::Multiplex>).  See
  135. examples/samplechat.pl for an example using most of the
  136. features of Net::Server::Multiplex.
  137.  
  138. =item PreForkSimple
  139.  
  140. Found in the module Net/Server/PreFork.pm (see
  141. L<Net::Server::PreFork>).  This server binds to one or more
  142. ports and then forks C<max_servers> child process.  The
  143. server will make sure that at any given time there are always
  144. C<max_servers> available to receive a client request.  Each
  145. of these children will process up to C<max_requests> client
  146. connections.  This type is good for a heavily hit site that
  147. can dedicate max_server processes no matter what the load.
  148. It should scale well for most applications.  Multi port accept
  149. is accomplished using either flock, IPC::Semaphore, or pipe to serialize the
  150. children.  Serialization may also be switched on for single
  151. port in order to get around an OS that does not allow multiple
  152. children to accept at the same time.  For a further
  153. discussion of serialization see L<Net::Server::PreFork>.
  154.  
  155. =item PreFork
  156.  
  157. Found in the module Net/Server/PreFork.pm (see
  158. L<Net::Server::PreFork>).  This server binds to one or more
  159. ports and then forks C<min_servers> child process.  The
  160. server will make sure that at any given time there are
  161. at least C<min_spare_servers> but not more than C<max_spare_servers>
  162. available to receive a client request, up
  163. to C<max_servers>.  Each of these children will process up
  164. to C<max_requests> client connections.  This type is good
  165. for a heavily hit site, and should scale well for most
  166. applications.  Multi port accept is accomplished using
  167. either flock, IPC::Semaphore, or pipe to serialize the
  168. children.  Serialization may also be switched on for single
  169. port in order to get around an OS that does not allow multiple
  170. children to accept at the same time.  For a further
  171. discussion of serialization see L<Net::Server::PreFork>.
  172.  
  173. =item Single
  174.  
  175. All methods fall back to Net::Server.  This personality is
  176. provided only as parallelism for Net::Server::MultiType.
  177.  
  178. =back
  179.  
  180. C<Net::Server> was partially written to make it easy to add
  181. new personalities.  Using separate modules built upon an
  182. open architecture allows for easy addition of new features,
  183. a separate development process, and reduced code bloat in
  184. the core module.
  185.  
  186. =head1 SOCKET ACCESS
  187.  
  188. Once started, the Net::Server will take care of binding to
  189. port and waiting for connections.  Once a connection is
  190. received, the Net::Server will accept on the socket and
  191. will store the result (the client connection) in
  192. $self-E<gt>{server}-E<gt>{client}.  This property is a
  193. Socket blessed into the the IO::Socket classes.  UDP
  194. servers are slightly different in that they will perform
  195. a B<recv> instead of an B<accept>.
  196.  
  197. To make programming easier, during the post_accept phase,
  198. STDIN and STDOUT are opened to the client connection.  This
  199. allows for programs to be written using E<lt>STDINE<gt> and
  200. print "out\n" to print to the client connection.  UDP will
  201. require using a -E<gt>send call.
  202.  
  203. =head1 SAMPLE CODE
  204.  
  205. The following is a very simple server.  The main
  206. functionality occurs in the process_request method call as
  207. shown below.  Notice the use of timeouts to prevent Denial
  208. of Service while reading.  (Other examples of using
  209. C<Net::Server> can, or will, be included with this distribution).
  210.  
  211.     #!/usr/bin/perl -w -T
  212.  
  213.     package MyPackage;
  214.  
  215.     use strict;
  216.     use base qw(Net::Server::PreFork); # any personality will do
  217.  
  218.     MyPackage->run;
  219.  
  220.     ### over-ridden subs below
  221.  
  222.     sub process_request {
  223.         my $self = shift;
  224.         eval {
  225.  
  226.             local $SIG{'ALRM'} = sub { die "Timed Out!\n" };
  227.             my $timeout = 30; # give the user 30 seconds to type some lines
  228.  
  229.             my $previous_alarm = alarm($timeout);
  230.             while (<STDIN>) {
  231.                 s/\r?\n$//;
  232.                 print "You said '$_'\r\n";
  233.                 alarm($timeout);
  234.             }
  235.             alarm($previous_alarm);
  236.  
  237.         };
  238.  
  239.         if ($@ =~ /timed out/i) {
  240.             print STDOUT "Timed Out.\r\n";
  241.             return;
  242.         }
  243.  
  244.     }
  245.  
  246.     1;
  247.  
  248. Playing this file from the command line will invoke a
  249. Net::Server using the PreFork personality.  When building a
  250. server layer over the Net::Server, it is important to use
  251. features such as timeouts to prevent Denial Of Service
  252. attacks.
  253.  
  254. =head1 ARGUMENTS
  255.  
  256. There are five possible ways to pass arguments to
  257. Net::Server.  They are I<passing to the new method>, I<passing on
  258. command line>, I<passing parameters to run>, I<using a conf file>,
  259. I<returning values in the default_values method>, or I<configuring the
  260. values in post_configure_hook>.
  261.  
  262. The C<options> method is used to determine which arguments the server
  263. will search for and can be used to extend the parsed parameters.  Any
  264. arguments found from the command line, parameters passed to run, and
  265. arguments found in the conf_file will be matched against the keys of
  266. the options template.  Any commandline parameters that do not match
  267. will be left in place and can be further processed by the server in
  268. the various hooks (by looking at @ARGV).  Arguments passed to new will
  269. automatically win over any other options (this can be used if you
  270. would like to disallow a user passing in other arguments).
  271.  
  272. Arguments consist of key value pairs.  On the commandline
  273. these pairs follow the POSIX fashion of C<--key value> or
  274. C<--key=value>, and also C<key=value>.  In the conf file the
  275. parameter passing can best be shown by the following regular
  276. expression: ($key,$val)=~/^(\w+)\s+(\S+?)\s+$/.  Passing
  277. arguments to the run method is done as follows:
  278. C<Net::Server->run(key1 => 'val1')>.  Passing arguments via
  279. a prebuilt object can best be shown in the following code:
  280.  
  281.     #!/usr/bin/perl -w -T
  282.  
  283.     package MyPackage;
  284.     use strict;
  285.     use base qw(Net::Server);
  286.  
  287.     my $server = MyPackage->new({
  288.         key1 => 'val1',
  289.     });
  290.  
  291.     $server->run;
  292.  
  293. All five methods for passing arguments may be used at the
  294. same time.  Once an argument has been set, it is not over
  295. written if another method passes the same argument.  C<Net::Server>
  296. will look for arguments in the following order:
  297.  
  298.   1) Arguments passed to the C<new> method.
  299.   2) Arguments passed on command line.
  300.   3) Arguments passed to the C<run> method.
  301.   4) Arguments passed via a conf file.
  302.   5) Arguments set in the C<default_values> method.
  303.  
  304. Additionally the following hooks are available:
  305.  
  306.   1) Arguments set in the configure_hook (occurs after new
  307.      but before any of the other areas are checked).
  308.   2) Arguments set and validated in the post_configure_hook
  309.      (occurs after all of the other areas are checked).
  310.  
  311. Each of these levels will override parameters of the same
  312. name specified in subsequent levels.  For example, specifying
  313. --setsid=0 on the command line will override a value of "setsid 1"
  314. in the conf file.
  315.  
  316. Note that the configure_hook method doesn't return values
  317. to set, but is there to allow for setting up configured values
  318. before the configure method is called.
  319.  
  320. Key/value pairs used by the server are removed by the
  321. configuration process so that server layers on top of
  322. C<Net::Server> can pass and read their own parameters.
  323.  
  324. =head1 ADDING CUSTOM ARGUMENTS
  325.  
  326. It is possible to add in your own custom parameters to those parsed
  327. by Net::Server.  The following code shows how this is done:
  328.  
  329.     sub options {
  330.         my $self     = shift;
  331.         my $prop     = $self->{'server'};
  332.         my $template = shift;
  333.  
  334.         ### setup options in the parent classes
  335.         $self->SUPER::options($template);
  336.  
  337.         ### add a single value option
  338.         $prop->{'my_option'} ||= undef;
  339.         $template->{'my_option'} = \ $prop->{'my_option'};
  340.  
  341.         ### add a multi value option
  342.         $prop->{'an_arrayref_item'} ||= [];
  343.         $template->{'an_arrayref_item'} = $prop->{'an_arrayref_item'};
  344.     }
  345.  
  346. Overriding the C<options> method allows for adding your own custom
  347. fields.  A template hashref is passed in, that should then be modified
  348. to contain an of your custom fields.  Fields which are intended to
  349. receive a single scalar value should have a reference to the
  350. destination scalar given.  Fields which are intended to receive
  351. multiple values should reference the corresponding destination
  352. arrayref.
  353.  
  354. You are responsible for validating your custom options once they have
  355. been parsed.  The post_configure_hook is a good place to do your
  356. validation.
  357.  
  358. Some emails have asked why we use this "template" method.  The idea is
  359. that you are creating the the data structure to store the values in,
  360. and you are also creating a way to get the values into the data
  361. structure.  The template is the way to get the values to the servers
  362. data structure.  One of the possibilities (that probably isn't used
  363. that much) is that by letting you specify the mapping, you could build
  364. a nested data structure - even though the passed in arguments are
  365. flat.  It also allows you to setup aliases to your names.
  366.  
  367. For example, a basic structure might look like this:
  368.  
  369.    $prop = $self->{'server'}
  370.  
  371.    $prop->{'my_custom_option'} ||= undef;
  372.    $prop->{'my_custom_array'}  ||= [];
  373.  
  374.    $template = {
  375.       my_custom_option => \ $prop->{'my_custom_option'},
  376.       mco              => \ $prop->{'my_custom_option'}, # alias
  377.       my_custom_array  => $prop->{'my_custom_array'},
  378.       mca              => $prop->{'my_custom_array'}, # an alias
  379.    };
  380.  
  381.    $template->{'mco2'} = $template->{'mco'}; # another way to alias
  382.  
  383. But you could also have more complex data:
  384.  
  385.    $prop = $self->{'server'};
  386.  
  387.    $prop->{'one_layer'} = {
  388.        two_layer => [
  389.            undef,
  390.            undef,
  391.        ],
  392.    };
  393.  
  394.    $template = {
  395.         param1 => \ $prop->{'one_layer'}->{'two_layer'}->[0],
  396.         param2 => \ $prop->{'one_layer'}->{'two_layer'}->[1],
  397.    };
  398.  
  399. This is of course a contrived example - but it does show that you can
  400. get the data from the flat passed in arguments to whatever type of
  401. structure you need - with only a little bit of effort.
  402.  
  403. =head1 DEFAULT ARGUMENTS FOR Net::Server
  404.  
  405. The following arguments are available in the default C<Net::Server> or
  406. C<Net::Server::Single> modules.  (Other personalities may use
  407. additional parameters and may optionally not use parameters from the
  408. base class.)
  409.  
  410.   Key               Value                    Default
  411.   conf_file         "filename"               undef
  412.  
  413.   log_level         0-4                      2
  414.   log_file          (filename|Sys::Syslog)   undef
  415.  
  416.   ## syslog parameters
  417.   syslog_logsock    (native|unix|inet|udp
  418.                      |tcp|stream|console)    unix (on Sys::Syslog < 0.15)
  419.   syslog_ident      "identity"               "net_server"
  420.   syslog_logopt     (cons|ndelay|nowait|pid) pid
  421.   syslog_facility   \w+                      daemon
  422.  
  423.   port              \d+                      20203
  424.   host              "host"                   "*"
  425.   proto             (tcp|udp|unix)           "tcp"
  426.   listen            \d+                      SOMAXCONN
  427.  
  428.   reverse_lookups   1                        undef
  429.   allow             /regex/                  none
  430.   deny              /regex/                  none
  431.   cidr_allow        CIDR                     none
  432.   cidr_deny         CIDR                     none
  433.  
  434.   ## daemonization parameters
  435.   pid_file          "filename"               undef
  436.   chroot            "directory"              undef
  437.   user              (uid|username)           "nobody"
  438.   group             (gid|group)              "nobody"
  439.   background        1                        undef
  440.   setsid            1                        undef
  441.  
  442.   no_close_by_child (1|undef)                undef
  443.  
  444.   ## See Net::Server::Proto::(TCP|UDP|UNIX|etc)
  445.   ## for more sample parameters.
  446.  
  447. =over 4
  448.  
  449. =item conf_file
  450.  
  451. Filename from which to read additional key value pair arguments
  452. for starting the server.  Default is undef.
  453.  
  454. There are two ways that you can specify a default location for
  455. a conf_file.  The first is to pass the default value to the run
  456. method as in:
  457.  
  458.     MyServer->run({
  459.        conf_file => '/etc/my_server.conf',
  460.     });
  461.  
  462. If the end user passes in --conf_file=/etc/their_server.conf then
  463. the value will be overridden.
  464.  
  465. The second way to do this was added in the 0.96 version.  It uses
  466. the default_values method as in:
  467.  
  468.     sub default_values {
  469.         return {
  470.             conf_file => '/etc/my_server.conf',
  471.         }
  472.     }
  473.  
  474. This method has the advantage of also being able to be overridden
  475. in the run method.
  476.  
  477. If you do not want the user to be able to specify a conf_file at
  478. all, you can pass conf_file to the new method when creating your
  479. object:
  480.  
  481.     MyServer->new({
  482.        conf_file => '/etc/my_server.conf',
  483.     })->run;
  484.  
  485. If passed this way, the value passed to new will "win" over any of
  486. the other passed in values.
  487.  
  488. =item log_level
  489.  
  490. Ranges from 0 to 4 in level.  Specifies what level of error
  491. will be logged.  "O" means logging is off.  "4" means very
  492. verbose.  These levels should be able to correlate to syslog
  493. levels.  Default is 2.  These levels correlate to syslog levels
  494. as defined by the following key/value pairs: 0=>'err',
  495. 1=>'warning', 2=>'notice', 3=>'info', 4=>'debug'.
  496.  
  497. =item log_file
  498.  
  499. Name of log file to be written to.  If no name is given and
  500. hook is not overridden, log goes to STDERR.  Default is undef.
  501. If the magic name "Sys::Syslog" is used, all logging will
  502. take place via the Sys::Syslog module.  If syslog is used
  503. the parameters C<syslog_logsock>, C<syslog_ident>, and
  504. C<syslog_logopt>,and C<syslog_facility> may also be defined.
  505. If a C<log_file> is given or if C<setsid> is set, STDIN and
  506. STDOUT will automatically be opened to /dev/null and STDERR
  507. will be opened to STDOUT.  This will prevent any output
  508. from ending up at the terminal.
  509.  
  510. =item pid_file
  511.  
  512. Filename to store pid of parent process.  Generally applies
  513. only to forking servers.  Default is none (undef).
  514.  
  515. =item syslog_logsock
  516.  
  517. Only available if C<log_file> is equal to "Sys::Syslog".  May
  518. be either unix, inet, native, console, stream, udp, or tcp, or
  519. an arrayref of the types to try.  Default is "unix" if the version
  520. of Sys::Syslog < 0.15 - otherwise the default is to not call
  521. setlogsock.
  522.  
  523. See L<Sys::Syslog>.
  524.  
  525. =item syslog_ident
  526.  
  527. Only available if C<log_file> is equal to "Sys::Syslog".  Id
  528. to prepend on syslog entries.  Default is "net_server".
  529. See L<Sys::Syslog>.
  530.  
  531. =item syslog_logopt
  532.  
  533. Only available if C<log_file> is equal to "Sys::Syslog".  May
  534. be either zero or more of "pid","cons","ndelay","nowait".
  535. Default is "pid".  See L<Sys::Syslog>.
  536.  
  537. =item syslog_facility
  538.  
  539. Only available if C<log_file> is equal to "Sys::Syslog".
  540. See L<Sys::Syslog> and L<syslog>.  Default is "daemon".
  541.  
  542. =item port
  543.  
  544. See L<Net::Server::Proto>.
  545. Local port/socket on which to bind.  If low port, process must
  546. start as root.  If multiple ports are given, all will be
  547. bound at server startup.  May be of the form
  548. C<host:port/proto>, C<host:port>, C<port/proto>, or C<port>,
  549. where I<host> represents a hostname residing on the local
  550. box, where I<port> represents either the number of the port
  551. (eg. "80") or the service designation (eg.  "http"), and
  552. where I<proto> represents the protocol to be used.  See
  553. L<Net::Server::Proto>.  If you are working with unix sockets,
  554. you may also specify C<socket_file|unix> or
  555. C<socket_file|type|unix> where type is SOCK_DGRAM or
  556. SOCK_STREAM.  If the protocol is not specified, I<proto> will
  557. default to the C<proto> specified in the arguments.  If C<proto> is not
  558. specified there it will default to "tcp".  If I<host> is not
  559. specified, I<host> will default to C<host> specified in the
  560. arguments.  If C<host> is not specified there it will
  561. default to "*".  Default port is 20203.  Configuration passed
  562. to new or run may be either a scalar containing a single port
  563. number or an arrayref of ports.
  564.  
  565. =item host
  566.  
  567. Local host or addr upon which to bind port.  If a value of '*' is
  568. given, the server will bind that port on all available addresses
  569. on the box.  See L<Net::Server::Proto>. See L<IO::Socket>.  Configuration
  570. passed to new or run may be either a scalar containing a single
  571. host or an arrayref of hosts - if the hosts array is shorter than
  572. the ports array, the last host entry will be used to augment the
  573. hosts arrary to the size of the ports array.
  574.  
  575. =item proto
  576.  
  577. See L<Net::Server::Proto>.
  578. Protocol to use when binding ports.  See L<IO::Socket>.  As
  579. of release 0.70, Net::Server supports tcp, udp, and unix.  Other
  580. types will need to be added later (or custom modules extending the
  581. Net::Server::Proto class may be used).  Configuration
  582. passed to new or run may be either a scalar containing a single
  583. proto or an arrayref of protos - if the protos array is shorter than
  584. the ports array, the last proto entry will be used to augment the
  585. protos arrary to the size of the ports array.
  586.  
  587. =item listen
  588.  
  589.   See L<IO::Socket>.  Not used with udp protocol (or UNIX SOCK_DGRAM).
  590.  
  591. =item reverse_lookups
  592.  
  593. Specify whether to lookup the hostname of the connected IP.
  594. Information is cached in server object under C<peerhost>
  595. property.  Default is to not use reverse_lookups (undef).
  596.  
  597. =item allow/deny
  598.  
  599. May be specified multiple times.  Contains regex to compare
  600. to incoming peeraddr or peerhost (if reverse_lookups has
  601. been enabled).  If allow or deny options are given, the
  602. incoming client must match an allow and not match a deny or
  603. the client connection will be closed.  Defaults to empty
  604. array refs.
  605.  
  606. =item cidr_allow/cidr_deny
  607.  
  608. May be specified multiple times.  Contains a CIDR block to compare to
  609. incoming peeraddr.  If cidr_allow or cidr_deny options are given, the
  610. incoming client must match a cidr_allow and not match a cidr_deny or
  611. the client connection will be closed.  Defaults to empty array refs.
  612.  
  613. =item chroot
  614.  
  615. Directory to chroot to after bind process has taken place
  616. and the server is still running as root.  Defaults to
  617. undef.
  618.  
  619. =item user
  620.  
  621. Userid or username to become after the bind process has
  622. occured.  Defaults to "nobody."  If you would like the
  623. server to run as root, you will have to specify C<user>
  624. equal to "root".
  625.  
  626. =item group
  627.  
  628. Groupid or groupname to become after the bind process has
  629. occured.  Defaults to "nobody."  If you would like the
  630. server to run as root, you will have to specify C<group>
  631. equal to "root".
  632.  
  633. =item background
  634.  
  635. Specifies whether or not the server should fork after the
  636. bind method to release itself from the command line.
  637. Defaults to undef.  Process will also background if
  638. C<setsid> is set.
  639.  
  640. =item setsid
  641.  
  642. Specifies whether or not the server should fork after the
  643. bind method to release itself from the command line and then
  644. run the C<POSIX::setsid()> command to truly daemonize.
  645. Defaults to undef.  If a C<log_file> is given or if
  646. C<setsid> is set, STDIN and STDOUT will automatically be
  647. opened to /dev/null and STDERR will be opened to STDOUT.
  648. This will prevent any output from ending up at the terminal.
  649.  
  650. =item no_close_by_child
  651.  
  652. Boolean.  Specifies whether or not a forked child process has
  653. permission or not to shutdown the entire server process.  If set to 1,
  654. the child may NOT signal the parent to shutdown all children.  Default
  655. is undef (not set).
  656.  
  657. =item no_client_stdout
  658.  
  659. Boolean.  Default undef (not set).  Specifies that STDIN and STDOUT
  660. should not be opened on the client handle once a connection has been
  661. accepted.  By default the Net::Server will open STDIN and STDOUT on
  662. the client socket making it easier for many types of scripts to read
  663. directly from and write directly to the socket using normal print and
  664. read methods.  Disabling this is useful on clients that may be opening
  665. their own connections to STDIN and STDOUT.
  666.  
  667. This option has no affect on STDIN and STDOUT which has a magic client
  668. property that is tied to the already open STDIN and STDOUT.
  669.  
  670. =item leave_children_open_on_hup
  671.  
  672. Boolean.  Default undef (not set).  If set, the parent will not attempt
  673. to close child processes if the parent receives a SIG HUP.  The parent
  674. will rebind the the open port and begin tracking a fresh set of children.
  675.  
  676. Children of a Fork server will exit after their current request.  Children
  677. of a Prefork type server will finish the current request and then exit.
  678.  
  679. Note - the newly restarted parent will start up a fresh set of servers on
  680. fork servers.  The new parent will attempt to keep track of the children from
  681. the former parent but custom communication channels (open pipes from the child
  682. to the old parent) will no longer be available to the old child processes.  New
  683. child processes will still connect properly to the new parent.
  684.  
  685. =back
  686.  
  687. =head1 PROPERTIES
  688.  
  689. All of the C<ARGUMENTS> listed above become properties of
  690. the server object under the same name.  These properties, as
  691. well as other internal properties, are available during
  692. hooks and other method calls.
  693.  
  694. The structure of a Net::Server object is shown below:
  695.  
  696.   $self = bless( {
  697.                    'server' => {
  698.                                  'key1' => 'val1',
  699.                                  # more key/vals
  700.                                }
  701.                  }, 'Net::Server' );
  702.  
  703. This structure was chosen so that all server related
  704. properties are grouped under a single key of the object
  705. hashref.  This is so that other objects could layer on top
  706. of the Net::Server object class and still have a fairly
  707. clean namespace in the hashref.
  708.  
  709. You may get and set properties in two ways.  The suggested
  710. way is to access properties directly via
  711.  
  712.   my $val = $self->{server}->{key1};
  713.  
  714. Accessing the properties directly will speed the server process -
  715. though some would deem this as bad style.  A second way has been
  716. provided for object oriented types who believe in methods.  The second
  717. way consists of the following methods:
  718.  
  719.   my $val = $self->get_property( 'key1' );
  720.   my $self->set_property( key1 => 'val1' );
  721.  
  722. Properties are allowed to be changed at any time with
  723. caution (please do not undef the sock property or you will
  724. close the client connection).
  725.  
  726. =head1 CONFIGURATION FILE
  727.  
  728. C<Net::Server> allows for the use of a configuration file to
  729. read in server parameters.  The format of this conf file is
  730. simple key value pairs.  Comments and blank lines are
  731. ignored.
  732.  
  733.   #-------------- file test.conf --------------
  734.  
  735.   ### user and group to become
  736.   user        somebody
  737.   group       everybody
  738.  
  739.   ### logging ?
  740.   log_file    /var/log/server.log
  741.   log_level   3
  742.   pid_file    /tmp/server.pid
  743.  
  744.   ### optional syslog directive
  745.   ### used in place of log_file above
  746.   #log_file       Sys::Syslog
  747.   #syslog_logsock unix
  748.   #syslog_ident   myserver
  749.   #syslog_logopt  pid|cons
  750.  
  751.   ### access control
  752.   allow       .+\.(net|com)
  753.   allow       domain\.com
  754.   deny        a.+
  755.   cidr_allow  127.0.0.0/8
  756.   cidr_allow  192.0.2.0/24
  757.   cidr_deny   192.0.2.4/30
  758.  
  759.   ### background the process?
  760.   background  1
  761.  
  762.   ### ports to bind (this should bind
  763.   ### 127.0.0.1:20205 and localhost:20204)
  764.   ### See Net::Server::Proto
  765.   host        127.0.0.1
  766.   port        localhost:20204
  767.   port        20205
  768.  
  769.   ### reverse lookups ?
  770.   # reverse_lookups on
  771.  
  772.   #-------------- file test.conf --------------
  773.  
  774. =head1 PROCESS FLOW
  775.  
  776. The process flow is written in an open, easy to
  777. override, easy to hook, fashion.  The basic flow is
  778. shown below.  This is the flow of the C<$self-E<gt>run> method.
  779.  
  780.   $self->configure_hook;
  781.  
  782.   $self->configure(@_);
  783.  
  784.   $self->post_configure;
  785.  
  786.   $self->post_configure_hook;
  787.  
  788.   $self->pre_bind;
  789.  
  790.   $self->bind;
  791.  
  792.   $self->post_bind_hook;
  793.  
  794.   $self->post_bind;
  795.  
  796.   $self->pre_loop_hook;
  797.  
  798.   $self->loop;
  799.  
  800.   ### routines inside a standard $self->loop
  801.   # $self->accept;
  802.   # $self->run_client_connection;
  803.   # $self->done;
  804.  
  805.   $self->pre_server_close_hook;
  806.  
  807.   $self->server_close;
  808.  
  809. The server then exits.
  810.  
  811. During the client processing phase
  812. (C<$self-E<gt>run_client_connection>), the following
  813. represents the program flow:
  814.  
  815.   $self->post_accept;
  816.  
  817.   $self->get_client_info;
  818.  
  819.   $self->post_accept_hook;
  820.  
  821.   if( $self->allow_deny
  822.  
  823.       && $self->allow_deny_hook ){
  824.  
  825.     $self->process_request;
  826.  
  827.   }else{
  828.  
  829.     $self->request_denied_hook;
  830.  
  831.   }
  832.  
  833.   $self->post_process_request_hook;
  834.  
  835.   $self->post_process_request;
  836.  
  837.   $self->post_client_connection_hook;
  838.  
  839. The process then loops and waits for the next
  840. connection.  For a more in depth discussion, please
  841. read the code.
  842.  
  843. During the server shutdown phase
  844. (C<$self-E<gt>server_close>), the following
  845. represents the program flow:
  846.  
  847.   $self->close_children;  # if any
  848.  
  849.   $self->post_child_cleanup_hook;
  850.  
  851.   if( Restarting server ){
  852.      $self->restart_close_hook();
  853.      $self->hup_server;
  854.   }
  855.  
  856.   $self->shutdown_sockets;
  857.  
  858.   $self->server_exit;
  859.  
  860. =head1 MAIN SERVER METHODS
  861.  
  862. =over 4
  863.  
  864. =item C<$self-E<gt>run>
  865.  
  866. This method incorporates the main process flow.  This flow
  867. is listed above.
  868.  
  869. The method run may be called in any of the following ways.
  870.  
  871.    MyPackage->run(port => 20201);
  872.  
  873.    MyPackage->new({port => 20201})->run;
  874.  
  875.    my $obj = bless {server=>{port => 20201}}, 'MyPackage';
  876.    $obj->run;
  877.  
  878. The ->run method should typically be the last method called
  879. in a server start script (the server will exit at the end
  880. of the ->run method).
  881.  
  882. =item C<$self-E<gt>configure>
  883.  
  884. This method attempts to read configurations from the commandline,
  885. from the run method call, or from a specified conf_file (the conf_file
  886. may be specified by passed in parameters, or in the default_values).
  887. All of the configured parameters are then stored in the {"server"}
  888. property of the Server object.
  889.  
  890. =item C<$self-E<gt>post_configure>
  891.  
  892. The post_configure hook begins the startup of the server.  During
  893. this method running server instances are checked for, pid_files are created,
  894. log_files are created, Sys::Syslog is initialized (as needed), process
  895. backgrounding occurs and the server closes STDIN and STDOUT (as needed).
  896.  
  897. =item C<$self-E<gt>pre_bind>
  898.  
  899. This method is used to initialize all of the socket objects
  900. used by the server.
  901.  
  902. =item C<$self-E<gt>bind>
  903.  
  904. This method actually binds to the inialized sockets (or rebinds
  905. if the server has been HUPed).
  906.  
  907. =item C<$self-E<gt>post_bind>
  908.  
  909. During this method priveleges are dropped.
  910. The INT, TERM, and QUIT signals are set to run server_close.
  911. Sig PIPE is set to IGNORE.  Sig CHLD is set to sig_chld.  And sig
  912. HUP is set to call sig_hup.
  913.  
  914. Under the Fork, PreFork, and PreFork simple personalities, these
  915. signals are registered using Net::Server::SIG to allow for
  916. safe signal handling.
  917.  
  918. =item C<$self-E<gt>loop>
  919.  
  920. During this phase, the server accepts incoming connections.
  921. The behavior of how the accepting occurs and if a child process
  922. handles the connection is controlled by what type of Net::Server
  923. personality the server is using.
  924.  
  925. Net::Server and Net::Server single accept only one connection at
  926. a time.
  927.  
  928. Net::Server::INET runs one connection and then exits (for use by
  929. inetd or xinetd daemons).
  930.  
  931. Net::Server::MultiPlex allows for one process to simultaneously
  932. handle multiple connections (but requires rewriting the process_request
  933. code to operate in a more "packet-like" manner).
  934.  
  935. Net::Server::Fork forks off a new child process for each incoming
  936. connection.
  937.  
  938. Net::Server::PreForkSimple starts up a fixed number of processes
  939. that all accept on incoming connections.
  940.  
  941. Net::Server::PreFork starts up a base number of child processes
  942. which all accept on incoming connections.  The server throttles
  943. the number of processes running depending upon the number of
  944. requests coming in (similar to concept to how Apache controls
  945. its child processes in a PreFork server).
  946.  
  947. Read the documentation for each of the types for more information.
  948.  
  949. =item C<$self-E<gt>server_close>
  950.  
  951. This method is called once the server has been signaled to end, or
  952. signaled for the server to restart (via HUP),  or the loop
  953. method has been exited.
  954.  
  955. This method takes care of cleaning up any remaining child processes,
  956. setting appropriate flags on sockets (for HUPing), closing up
  957. logging, and then closing open sockets.
  958.  
  959. =item C<$self-E<gt>server_exit>
  960.  
  961. This method is called at the end of server_close.  It calls exit,
  962. but may be overridden to do other items.  At this point all services
  963. should be shut down.
  964.  
  965. =back
  966.  
  967. =head1 MAIN CLIENT CONNECTION METHODS
  968.  
  969. =over 4
  970.  
  971. =item C<$self-E<gt>run_client_connection>
  972.  
  973. This method is run after the server has accepted and received
  974. a client connection.  The full process flow is listed
  975. above under PROCESS FLOWS.  This method takes care of
  976. handling each client connection.
  977.  
  978. =item C<$self-E<gt>post_accept>
  979.  
  980. This method opens STDIN and STDOUT to the client socket.
  981. This allows any of the methods during the run_client_connection
  982. phase to print directly to and read directly from the
  983. client socket.
  984.  
  985. =item C<$self-E<gt>get_client_info>
  986.  
  987. This method looks up information about the client connection
  988. such as ip address, socket type, and hostname (as needed).
  989.  
  990. =item C<$self-E<gt>allow_deny>
  991.  
  992. This method uses the rules defined in the allow and deny configuration
  993. parameters to determine if the ip address should be accepted.
  994.  
  995. =item C<$self-E<gt>process_request>
  996.  
  997. This method is intended to handle all of the client communication.
  998. At this point STDIN and STDOUT are opened to the client, the ip
  999. address has been verified.  The server can then
  1000. interact with the client connection according to whatever API or
  1001. protocol the server is implementing.  Note that the stub implementation
  1002. uses STDIN and STDOUT and will not work if the no_client_stdout flag
  1003. is set.
  1004.  
  1005. This is the main method to override.
  1006.  
  1007. The default method implements a simple echo server that
  1008. will repeat whatever is sent.  It will quit the child if "quit"
  1009. is sent, and will exit the server if "exit" is sent.
  1010.  
  1011. =item C<$self-E<gt>post_process_request>
  1012.  
  1013. This method is used to clean up the client connection and
  1014. to handle any parent/child accounting for the forking servers.
  1015.  
  1016. =back
  1017.  
  1018. =head1 HOOKS
  1019.  
  1020. C<Net::Server> provides a number of "hooks" allowing for
  1021. servers layered on top of C<Net::Server> to respond at
  1022. different levels of execution without having to "SUPER" class
  1023. the main built-in methods.  The placement of the hooks
  1024. can be seen in the PROCESS FLOW section.
  1025.  
  1026. Almost all of the default hook methods do nothing.  To use a hook
  1027. you simply need to override the method in your subclass.  For example
  1028. to add your own post_configure_hook you could do something like the following:
  1029.  
  1030.     package MyServer;
  1031.  
  1032.     sub post_configure_hook {
  1033.         my $self = shift;
  1034.         my $prop = $self->{'server'};
  1035.  
  1036.         # do some validation here
  1037.     }
  1038.  
  1039. The following describes the hooks available in the plain Net::Server class
  1040. (other flavors such as Fork or PreFork have additional hooks).
  1041.  
  1042. =over 4
  1043.  
  1044. =item C<$self-E<gt>configure_hook()>
  1045.  
  1046. This hook takes place immediately after the C<-E<gt>run()>
  1047. method is called.  This hook allows for setting up the
  1048. object before any built in configuration takes place.
  1049. This allows for custom configurability.
  1050.  
  1051. =item C<$self-E<gt>post_configure_hook()>
  1052.  
  1053. This hook occurs just after the reading of configuration
  1054. parameters and initiation of logging and pid_file creation.
  1055. It also occurs before the C<-E<gt>pre_bind()> and
  1056. C<-E<gt>bind()> methods are called.  This hook allows for
  1057. verifying configuration parameters.
  1058.  
  1059. =item C<$self-E<gt>post_bind_hook()>
  1060.  
  1061. This hook occurs just after the bind process and just before
  1062. any chrooting, change of user, or change of group occurs.
  1063. At this point the process will still be running as the user
  1064. who started the server.
  1065.  
  1066. =item C<$self-E<gt>pre_loop_hook()>
  1067.  
  1068. This hook occurs after chroot, change of user, and change of
  1069. group has occured.  It allows for preparation before looping
  1070. begins.
  1071.  
  1072. =item C<$self-E<gt>can_read_hook()>
  1073.  
  1074. This hook occurs after a socket becomes readible on an
  1075. accept_multi_port request (accept_multi_port is used if there are
  1076. multiple bound ports to accept on, or if the "multi_port"
  1077. configuration parameter is set to true).  This hook is intended to
  1078. allow for processing of arbitrary handles added to the IO::Select used
  1079. for the accept_multi_port.  These handles could be added during the
  1080. post_bind_hook.  No internal support is added for processing these
  1081. handles or adding them to the IO::Socket.  Care must be used in how
  1082. much occurs during the can_read_hook as a long response time will
  1083. result in the server being susceptible to DOS attacks.  A return value
  1084. of true indicates that the Server should not pass the readible handle
  1085. on to the post_accept and process_request phases.
  1086.  
  1087. It is generally suggested that other avenues be pursued for sending
  1088. messages via sockets not created by the Net::Server.
  1089.  
  1090. =item C<$self-E<gt>post_accept_hook()>
  1091.  
  1092. This hook occurs after a client has connected to the server.
  1093. At this point STDIN and STDOUT are mapped to the client
  1094. socket.  This hook occurs before the processing of the
  1095. request.
  1096.  
  1097. =item C<$self-E<gt>allow_deny_hook()>
  1098.  
  1099. This hook allows for the checking of ip and host information
  1100. beyond the C<$self-E<gt>allow_deny()> routine.  If this hook
  1101. returns 1, the client request will be processed,
  1102. otherwise, the request will be denied processing.
  1103.  
  1104. =item C<$self-E<gt>request_denied_hook()>
  1105.  
  1106. This hook occurs if either the C<$self-E<gt>allow_deny()> or
  1107. C<$self-E<gt>allow_deny_hook()> have taken place.
  1108.  
  1109. =item C<$self-E<gt>post_process_request_hook()>
  1110.  
  1111. This hook occurs after the processing of the request, but
  1112. before the client connection has been closed.
  1113.  
  1114. =item C<$self-E<gt>post_client_connection_hook>
  1115.  
  1116. This is one final hook that occurs at the very end of the
  1117. run_client_connection method.  At this point all other methods
  1118. and hooks that will run during the run_client_connection
  1119. have finished and the client connection has already been closed.
  1120.  
  1121. =item C<$self-E<gt>pre_server_close_hook()>
  1122.  
  1123. This hook occurs before the server begins shutting down.
  1124.  
  1125. =item C<$self-E<gt>write_to_log_hook>
  1126.  
  1127. This hook handles writing to log files.  The default hook
  1128. is to write to STDERR, or to the filename contained in
  1129. the parameter C<log_file>.  The arguments passed are a
  1130. log level of 0 to 4 (4 being very verbose), and a log line.
  1131. If log_file is equal to "Sys::Syslog", then logging will
  1132. go to Sys::Syslog and will bypass the write_to_log_hook.
  1133.  
  1134. =item C<$self-E<gt>fatal_hook>
  1135.  
  1136. This hook occurs when the server has encountered an
  1137. unrecoverable error.  Arguments passed are the error
  1138. message, the package, file, and line number.  The hook
  1139. may close the server, but it is suggested that it simply
  1140. return and use the built in shut down features.
  1141.  
  1142. =item C<$self-E<gt>post_child_cleanup_hook>
  1143.  
  1144. This hook occurs in the parent server process after all
  1145. children have been shut down and just before the server
  1146. either restarts or exits.  It is intended for additional
  1147. cleanup of information.  At this point pid_files and
  1148. lockfiles still exist.
  1149.  
  1150. =item C<$self-E<gt>restart_open_hook>
  1151.  
  1152. This hook occurs if a server has been HUPed (restarted
  1153. via the HUP signal.  It occurs just before reopening to
  1154. the filenos of the sockets that were already opened.
  1155.  
  1156. =item C<$self-E<gt>restart_close_hook>
  1157.  
  1158. This hook occurs if a server has been HUPed (restarted
  1159. via the HUP signal.  It occurs just before restarting the
  1160. server via exec.
  1161.  
  1162. =back
  1163.  
  1164. =head1 OTHER METHODS
  1165.  
  1166. =over 4
  1167.  
  1168. =item C<$self-E<gt>default_values>
  1169.  
  1170. Allow for returning configuration values that will be used if no
  1171. other value could be found.
  1172.  
  1173. Should return a hashref.
  1174.  
  1175.     sub default_values {
  1176.       return {
  1177.         port => 20201,
  1178.       };
  1179.     }
  1180.  
  1181. =item C<$self-E<gt>handle_syslog_error>
  1182.  
  1183. Called when log_file is set to 'Sys::Syslog' and an error occurs
  1184. while writing to the syslog.  It is passed two arguments, the
  1185. value of $@, and an arrayref containing the arguments that
  1186. were passed to the log method when the error occured.
  1187.  
  1188. =item C<$self-E<gt>log>
  1189.  
  1190. Parameters are a log_level and a message.
  1191.  
  1192. If log_level is set to 'Sys::Syslog', the parameters may alternately
  1193. be a log_level, a format string, and format string parameters.
  1194. (The second parameter is assumed to be a format string if additional
  1195. arguments are passed along).  Passing arbitrary format strings to
  1196. Sys::Syslog will allow the server to be vulnerable to exploit.  The
  1197. server maintainer should make sure that any string treated as
  1198. a format string is controlled.
  1199.  
  1200.     # assuming log_file = 'Sys::Syslog'
  1201.  
  1202.     $self->log(1, "My Message with %s in it");
  1203.     # sends "%s", "My Message with %s in it" to syslog
  1204.  
  1205.     $self->log(1, "My Message with %s in it", "Foo");
  1206.     # sends "My Message with %s in it", "Foo" to syslog
  1207.  
  1208. If log_file is set to a file (other than Sys::Syslog), the message
  1209. will be appended to the log file by calling the write_to_log_hook.
  1210.  
  1211. If the log_file is Sys::Syslog and an error occurs during write,
  1212. the handle_syslog_error method will be called and passed the
  1213. error exception.  The default option of handle_syslog_error is
  1214. to die - but could easily be told to do nothing by using the following
  1215. code in your subclassed server:
  1216.  
  1217.     sub handle_syslog_error {}
  1218.  
  1219. It the log had been closed, you could attempt to reopen it in the error
  1220. handler with the following code:
  1221.  
  1222.     sub handle_syslog_error {
  1223.       my $self = shift;
  1224.       $self->open_syslog;
  1225.     }
  1226.  
  1227. =item C<$self-E<gt>new>
  1228.  
  1229. As of Net::Server 0.91 there is finally a new method.  This method
  1230. takes a class name and an argument hashref as parameters.  The argument
  1231. hashref becomes the "server" property of the object.
  1232.  
  1233.    package MyPackage;
  1234.    use base qw(Net::Server);
  1235.  
  1236.    my $obj = MyPackage->new({port => 20201});
  1237.  
  1238.    # same as
  1239.  
  1240.    my $obj = bless {server => {port => 20201}}, 'MyPackage';
  1241.  
  1242. =item C<$self-E<gt>open_syslog>
  1243.  
  1244. Called during post_configure when the log_file option is set to 'Sys::Syslog'.
  1245. By default it use the parsed configuration options listed in this document.
  1246. If more custom behavior is desired, the method could be overridden and
  1247. Sys::Syslog::openlog should be called with the custom parameters.
  1248.  
  1249. =item C<$self-E<gt>shutdown_sockets>
  1250.  
  1251. This method will close any remaining open sockets.  This is called
  1252. at the end of the server_close method.
  1253.  
  1254. =back
  1255.  
  1256. =head1 RESTARTING
  1257.  
  1258. Each of the server personalities (except for INET), support
  1259. restarting via a HUP signal (see "kill -l").  When a HUP
  1260. is received, the server will close children (if any), make
  1261. sure that sockets are left open, and re-exec using
  1262. the same commandline parameters that initially started the
  1263. server.  (Note: for this reason it is important that @ARGV
  1264. is not modified until C<-E<gt>run> is called).
  1265.  
  1266. The Net::Server will attempt to find out the commandline used for
  1267. starting the program.  The attempt is made before any configuration
  1268. files or other arguments are processed.  The outcome of this attempt
  1269. is stored using the method C<-E<gt>commandline>.  The stored
  1270. commandline may also be retrieved using the same method name.  The
  1271. stored contents will undoubtedly contain Tainted items that will cause
  1272. the server to die during a restart when using the -T flag (Taint
  1273. mode).  As it is impossible to arbitrarily decide what is taint safe
  1274. and what is not, the individual program must clean up the tainted
  1275. items before doing a restart.
  1276.  
  1277.   sub configure_hook{
  1278.     my $self = shift;
  1279.  
  1280.     ### see the contents
  1281.     my $ref  = $self->commandline;
  1282.     use Data::Dumper;
  1283.     print Dumper $ref;
  1284.  
  1285.     ### arbitrary untainting - VERY dangerous
  1286.     my @untainted = map {/(.+)/;$1} @$ref;
  1287.  
  1288.     $self->commandline(\@untainted)
  1289.   }
  1290.  
  1291. =head1 FILES
  1292.  
  1293. The following files are installed as part of this
  1294. distribution.
  1295.  
  1296.     Net/Server.pm
  1297.     Net/Server/Fork.pm
  1298.     Net/Server/INET.pm
  1299.     Net/Server/MultiType.pm
  1300.     Net/Server/PreForkSimple.pm
  1301.     Net/Server/PreFork.pm
  1302.     Net/Server/Single.pm
  1303.     Net/Server/Daemonize.pm
  1304.     Net/Server/SIG.pm
  1305.     Net/Server/Proto.pm
  1306.     Net/Server/Proto/*.pm
  1307.  
  1308. =head1 INSTALL
  1309.  
  1310. Download and extract tarball before running
  1311. these commands in its base directory:
  1312.  
  1313.     perl Makefile.PL
  1314.     make
  1315.     make test
  1316.     make install
  1317.  
  1318. =head1 AUTHOR
  1319.  
  1320. Paul Seamons <paul at seamons.com>
  1321.  
  1322. =head1 THANKS
  1323.  
  1324. Thanks to Rob Brown (bbb at cpan.org) for help with
  1325. miscellaneous concepts such as tracking down the
  1326. serialized select via flock ala Apache and the reference
  1327. to IO::Select making multiport servers possible.  And for
  1328. researching into allowing sockets to remain open upon
  1329. exec (making HUP possible).
  1330.  
  1331. Thanks to Jonathan J. Miner <miner at doit.wisc.edu> for
  1332. patching a blatant problem in the reverse lookups.
  1333.  
  1334. Thanks to Bennett Todd <bet at rahul.net> for
  1335. pointing out a problem in Solaris 2.5.1 which does not
  1336. allow multiple children to accept on the same port at
  1337. the same time.  Also for showing some sample code
  1338. from Viktor Duchovni which now represents the semaphore
  1339. option of the serialize argument in the PreFork server.
  1340.  
  1341. Thanks to I<traveler> and I<merlyn> from http://perlmonks.org
  1342. for pointing me in the right direction for determining
  1343. the protocol used on a socket connection.
  1344.  
  1345. Thanks to Jeremy Howard <j+daemonize at howard.fm> for
  1346. numerous suggestions and for work on Net::Server::Daemonize.
  1347.  
  1348. Thanks to Vadim <vadim at hardison.net> for patches to
  1349. implement parent/child communication on PreFork.pm.
  1350.  
  1351. Thanks to Carl Lewis for suggesting "-" in user names.
  1352.  
  1353. Thanks to Slaven Rezic for suggesing Reuse => 1 in Proto::UDP.
  1354.  
  1355. Thanks to Tim Watt for adding udp_broadcast to Proto::UDP.
  1356.  
  1357. Thanks to Christopher A Bongaarts for pointing out problems with
  1358. the Proto::SSL implementation that currently locks around the socket
  1359. accept and the SSL negotiation. See L<Net::Server::Proto::SSL>.
  1360.  
  1361. Thanks to Alessandro Zummo for pointing out various bugs including
  1362. some in configuration, commandline args, and cidr_allow.
  1363.  
  1364. Thanks to various other people for bug fixes over the years.
  1365. These and future thank-you's are available in the Changes file
  1366. as well as CVS comments.
  1367.  
  1368. Thanks to Ben Cohen and tye (on Permonks) for finding and diagnosing
  1369. more correct behavior for dealing with re-opening STDIN and STDOUT on
  1370. the client handles.
  1371.  
  1372. Thanks to Mark Martinec for trouble shooting other problems with STDIN
  1373. and STDOUT (he proposed having a flag that is now the no_client_stdout
  1374. flag).
  1375.  
  1376. Thanks to David (DSCHWEI) on cpan for asking for the nofatal option
  1377. with syslog.
  1378.  
  1379. Thanks to Andreas Kippnick and Peter Beckman for suggesting leaving
  1380. open child connections open during a HUP (this is now available via
  1381. the leave_children_open_on_hup flag).
  1382.  
  1383. Thanks to LUPE on cpan for helping patch HUP with taint on.
  1384.  
  1385. Thanks to Michael Virnstein for fixing a bug in the check_for_dead
  1386. section of PreFork server.
  1387.  
  1388. Thanks to Rob Mueller for patching PreForkSimple to only open
  1389. lock_file once during parent call.  This patch should be portable on
  1390. systems supporting flock.  Rob also suggested not closing STDIN/STDOUT
  1391. but instead reopening them to /dev/null to prevent spurious warnings.
  1392. Also suggested short circuit in post_accept if in UDP.  Also for
  1393. cleaning up some of the child managment code of PreFork.
  1394.  
  1395. Thanks to Mark Martinec for suggesting additional log messages for
  1396. failure during accept.
  1397.  
  1398. Thanks to Bill Nesbitt and Carlos Velasco for pointing out double
  1399. decrement bug in PreFork.pm (rt #21271)
  1400.  
  1401. Thanks to John W. Krahn for pointing out glaring precended with
  1402. non-parened open and ||.
  1403.  
  1404. Thanks to Ricardo Signes for pointing out setuid bug for perl 5.6.1
  1405. (rt #21262).
  1406.  
  1407. Thanks to Carlos Velasco for updating the Syslog options (rt #21265).
  1408. And for additional fixes later.
  1409.  
  1410. Thanks to Steven Lembark for pointing out that no_client_stdout wasn't
  1411. working with the Multiplex server.
  1412.  
  1413. Thanks to Peter Beckman for suggesting allowing Sys::SysLog keyworks
  1414. be passed through the ->log method and for suggesting we allow more
  1415. types of characters through in syslog_ident.  Also to Peter Beckman
  1416. for pointing out that a poorly setup localhost will cause tests to
  1417. hang.
  1418.  
  1419. Thanks to Curtis Wilbar for pointing out that the Fork server called
  1420. post_accept_hook twice.  Changed to only let the child process call
  1421. this, but added the pre_fork_hook method.
  1422.  
  1423. And just a general Thanks You to everybody who is using Net::Server or
  1424. who has contributed fixes over the years.
  1425.  
  1426. Thanks to Paul Miller for some ->autoflush, FileHandle fixes.
  1427.  
  1428. Thanks to Patrik Wallstrom for suggesting handling syslog errors better.
  1429.  
  1430. Thanks again to Rob Mueller for more logic cleanup for child accounting in PreFork server.
  1431.  
  1432. Thanks to David Schweikert for suggesting handling setlogsock a little better on newer
  1433. versions of Sys::Syslog (>= 0.15).
  1434.  
  1435. Thanks to Mihail Nasedkin for suggesting adding a hook that is now
  1436. called post_client_connection_hook.
  1437.  
  1438. =head1 SEE ALSO
  1439.  
  1440. Please see also
  1441. L<Net::Server::Fork>,
  1442. L<Net::Server::INET>,
  1443. L<Net::Server::PreForkSimple>,
  1444. L<Net::Server::PreFork>,
  1445. L<Net::Server::MultiType>,
  1446. L<Net::Server::Single>
  1447.  
  1448. =head1 TODO
  1449.  
  1450.   Improve test suite to fully cover code (using Devel::Cover).  Anybody
  1451.   that wanted to send me patches to the t/*.t tests that improved coverage
  1452.   would earn a big thank you :) (Sorry there isn't a whole lot more than that to give).
  1453.  
  1454. =head1 AUTHOR
  1455.  
  1456.   Paul Seamons <paul at seamons.com>
  1457.   http://seamons.com/
  1458.  
  1459.   Rob Brown <bbb at cpan.org>
  1460.  
  1461. =head1 LICENSE
  1462.  
  1463. This package may be distributed under the terms of either the
  1464.  
  1465.   GNU General Public License
  1466.     or the
  1467.   Perl Artistic License
  1468.  
  1469. All rights reserved.
  1470.  
  1471. =cut
  1472.