Server IP : 103.119.228.120 / Your IP : 3.138.124.28 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/ssl/local/ssl/local/ssl/local/ssl/local/ssl/local/share/man/man3/ |
Upload File : |
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Net::Server 3" .TH Net::Server 3 "2014-05-06" "perl v5.16.3" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::Server \- Extensible, general Perl server engine .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #!/usr/bin/perl \-w \-T \& package MyPackage; \& \& use base qw(Net::Server); \& \& sub process_request { \& my $self = shift; \& while (<STDIN>) { \& s/[\er\en]+$//; \& print "You said \*(Aq$_\*(Aq\e015\e012"; # basic echo \& last if /quit/i; \& } \& } \& \& MyPackage\->run(port => 160, ipv => \*(Aq*\*(Aq); \& \& \& # one liner to get going quickly \& perl \-e \*(Aquse base qw(Net::Server); main\->run(port => 20208)\*(Aq \& \& NOTE: beginning in Net::Server 2.005, the default value for \& ipv is IPv* meaning that if no host is passed, or \& a hostname is past, any available IPv4 and IPv6 sockets will be \& bound. You can force IPv4 only by adding an ipv => 4 \& configuration in any of the half dozen ways we let you \& specify it. .Ve .SH "FEATURES" .IX Header "FEATURES" .Vb 10 \& * Full IPv6 support \& * Working SSL sockets and https (both with and without IO::Socket::SSL) \& * Single Server Mode \& * Inetd Server Mode \& * Preforking Simple Mode (PreForkSimple) \& * Preforking Managed Mode (PreFork) \& * Forking Mode \& * Multiplexing Mode using a single process \& * Multi port accepts on Single, Preforking, and Forking modes \& * Basic HTTP Daemon (supports IPv6, SSL, full apache style logs) \& * Basic PSGI Daemon \& * Simultaneous accept/recv on tcp/udp/unix, ssl/tcp, and IPv4/IPv6 sockets \& * Safe signal handling in Fork/PreFork avoids perl signal trouble \& * User customizable hooks \& * Chroot ability after bind \& * Change of user and group after bind \& * Basic allow/deny access control \& * Pluggable logging (Sys::Syslog, Log::Log4perl, log_file, STDERR, or your own) \& * HUP able server (clean restarts via sig HUP) \& * Graceful shutdowns (via sig QUIT) \& * Hot deploy in Fork and PreFork modes (via sig TTIN and TTOU) \& * Dequeue ability in all Fork and PreFork modes. \& * Taint clean \& * Written in Perl \& * Protection against buffer overflow \& * Clean process flow \& * Extensibility .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\f(CW\*(C`Net::Server\*(C'\fR is an extensible, generic Perl server engine. .PP \&\f(CW\*(C`Net::Server\*(C'\fR attempts to be a generic server as in \f(CW\*(C`Net::Daemon\*(C'\fR and \f(CW\*(C`NetServer::Generic\*(C'\fR. It includes with it the ability to run as an inetd process (\f(CW\*(C`Net::Server::INET\*(C'\fR), a single connection server (\f(CW\*(C`Net::Server\*(C'\fR or \f(CW\*(C`Net::Server::Single\*(C'\fR), a forking server (\f(CW\*(C`Net::Server::Fork\*(C'\fR), a preforking server which maintains a constant number of preforked children (\f(CW\*(C`Net::Server::PreForkSimple\*(C'\fR), or as a managed preforking server which maintains the number of children based on server load (\f(CW\*(C`Net::Server::PreFork\*(C'\fR). In all but the inetd type, the server provides the ability to connect to one or to multiple server ports. .PP The additional server types are made possible via \*(L"personalities\*(R" or sub classes of the \f(CW\*(C`Net::Server\*(C'\fR. By moving the multiple types of servers out of the main \f(CW\*(C`Net::Server\*(C'\fR class, the \f(CW\*(C`Net::Server\*(C'\fR concept is easily extended to other types (in the near future, we would like to add a \*(L"Thread\*(R" personality). .PP \&\f(CW\*(C`Net::Server\*(C'\fR borrows several concepts from the Apache Webserver. \&\f(CW\*(C`Net::Server\*(C'\fR uses \*(L"hooks\*(R" to allow custom servers such as \s-1SMTP, HTTP, POP3,\s0 etc. to be layered over the base \f(CW\*(C`Net::Server\*(C'\fR class. In addition the \f(CW\*(C`Net::Server::PreFork\*(C'\fR class borrows concepts of min_start_servers, max_servers, and min_waiting servers. \&\f(CW\*(C`Net::Server::PreFork\*(C'\fR also uses the concept of an flock serialized accept when accepting on multiple ports (PreFork can choose between flock, IPC::Semaphore, and pipe to control serialization). .SH "PERSONALITIES" .IX Header "PERSONALITIES" \&\f(CW\*(C`Net::Server\*(C'\fR is built around a common class (Net::Server) and is extended using sub classes, or \f(CW\*(C`personalities\*(C'\fR. Each personality inherits, overrides, or enhances the base methods of the base class. .PP Included with the Net::Server package are several basic personalities, each of which has their own use. .IP "Fork" 4 .IX Item "Fork" Found in the module Net/Server/Fork.pm (see Net::Server::Fork). This server binds to one or more ports and then waits for a connection. When a client request is received, the parent forks a child, which then handles the client and exits. This is good for moderately hit services. .IP "\s-1INET\s0" 4 .IX Item "INET" Found in the module Net/Server/INET.pm (see Net::Server::INET). This server is designed to be used with inetd. The \f(CW\*(C`pre_bind\*(C'\fR, \&\f(CW\*(C`bind\*(C'\fR, \f(CW\*(C`accept\*(C'\fR, and \f(CW\*(C`post_accept\*(C'\fR are all overridden as these services are taken care of by the \s-1INET\s0 daemon. .IP "MultiType" 4 .IX Item "MultiType" Found in the module Net/Server/MultiType.pm (see Net::Server::MultiType). This server has no server functionality of its own. It is designed for servers which need a simple way to easily switch between different personalities. Multiple \&\f(CW\*(C`server_type\*(C'\fR parameters may be given and Net::Server::MultiType will cycle through until it finds a class that it can use. .IP "Multiplex" 4 .IX Item "Multiplex" Found in the module Net/Server/Multiplex.pm (see Net::Server::Multiplex). This server binds to one or more ports. It uses IO::Multiplex to multiplex between waiting for new connections and waiting for input on currently established connections. This personality is designed to run as one process without forking. The \&\f(CW\*(C`process_request\*(C'\fR method is never used but the \f(CW\*(C`mux_input\*(C'\fR callback is used instead (see also IO::Multiplex). See examples/samplechat.pl for an example using most of the features of Net::Server::Multiplex. .IP "PreForkSimple" 4 .IX Item "PreForkSimple" Found in the module Net/Server/PreFork.pm (see Net::Server::PreFork). This server binds to one or more ports and then forks \f(CW\*(C`max_servers\*(C'\fR child process. The server will make sure that at any given time there are always \f(CW\*(C`max_servers\*(C'\fR available to receive a client request. Each of these children will process up to \&\f(CW\*(C`max_requests\*(C'\fR client connections. This type is good for a heavily hit site that can dedicate max_server processes no matter what the load. It should scale well for most applications. Multi port accept is accomplished using either flock, IPC::Semaphore, or pipe to serialize the children. Serialization may also be switched on for single port in order to get around an \s-1OS\s0 that does not allow multiple children to accept at the same time. For a further discussion of serialization see Net::Server::PreFork. .IP "PreFork" 4 .IX Item "PreFork" Found in the module Net/Server/PreFork.pm (see Net::Server::PreFork). This server binds to one or more ports and then forks \f(CW\*(C`min_servers\*(C'\fR child process. The server will make sure that at any given time there are at least \f(CW\*(C`min_spare_servers\*(C'\fR but not more than \f(CW\*(C`max_spare_servers\*(C'\fR available to receive a client request, up to \f(CW\*(C`max_servers\*(C'\fR. Each of these children will process up to \&\f(CW\*(C`max_requests\*(C'\fR client connections. This type is good for a heavily hit site, and should scale well for most applications. Multi port accept is accomplished using either flock, IPC::Semaphore, or pipe to serialize the children. Serialization may also be switched on for single port in order to get around an \s-1OS\s0 that does not allow multiple children to accept at the same time. For a further discussion of serialization see Net::Server::PreFork. .IP "Single" 4 .IX Item "Single" All methods fall back to Net::Server. This personality is provided only as parallelism for Net::Server::MultiType. .IP "\s-1HTTP\s0" 4 .IX Item "HTTP" Not a distinct personality. Provides a basic \s-1HTTP\s0 daemon. This can be combined with the \s-1SSL\s0 or \s-1SSLEAY\s0 proto to provide an \s-1HTTPS\s0 Daemon. See Net::Server::HTTP. .PP \&\f(CW\*(C`Net::Server\*(C'\fR was partially written to make it easy to add new personalities. Using separate modules built upon an open architecture allows for easy addition of new features, a separate development process, and reduced code bloat in the core module. .SH "SOCKET ACCESS" .IX Header "SOCKET ACCESS" Once started, the Net::Server will take care of binding to port and waiting for connections. Once a connection is received, the Net::Server will accept on the socket and will store the result (the client connection) in \f(CW$self\fR\->{server}\->{client}. This property is a Socket blessed into the the IO::Socket classes. \s-1UDP\s0 servers are slightly different in that they will perform a \fBrecv\fR instead of an \fBaccept\fR. .PP To make programming easier, during the post_accept phase, \s-1STDIN\s0 and \&\s-1STDOUT\s0 are opened to the client connection. This allows for programs to be written using <\s-1STDIN\s0> and print \*(L"out\en\*(R" to print to the client connection. \s-1UDP\s0 will require using a \->send call. .SH "SAMPLE CODE" .IX Header "SAMPLE CODE" The following is a very simple server. The main functionality occurs in the process_request method call as shown below. Notice the use of timeouts to prevent Denial of Service while reading. (Other examples of using \f(CW\*(C`Net::Server\*(C'\fR can, or will, be included with this distribution). .PP .Vb 1 \& #!/usr/bin/perl \-w \-T \& \& package MyPackage; \& \& use strict; \& use base qw(Net::Server::PreFork); # any personality will do \& \& MyPackage\->run; \& \& # over\-ride the default echo handler \& \& sub process_request { \& my $self = shift; \& eval { \& \& local $SIG{\*(AqALRM\*(Aq} = sub { die "Timed Out!\en" }; \& my $timeout = 30; # give the user 30 seconds to type some lines \& \& my $previous_alarm = alarm($timeout); \& while (<STDIN>) { \& s/\er?\en$//; \& print "You said \*(Aq$_\*(Aq\er\en"; \& alarm($timeout); \& } \& alarm($previous_alarm); \& \& }; \& \& if ($@ =~ /timed out/i) { \& print STDOUT "Timed Out.\er\en"; \& return; \& } \& \& } \& \& 1; .Ve .PP Playing this file from the command line will invoke a Net::Server using the PreFork personality. When building a server layer over the Net::Server, it is important to use features such as timeouts to prevent Denial Of Service attacks. .PP Net::Server comes with a built in echo server by default. You can test it out by simply running the following from the commandline: .PP .Vb 1 \& net\-server .Ve .PP If you wanted to try another flavor you could try .PP .Vb 1 \& net\-server PreFork .Ve .PP If you wanted to try out a basic \s-1HTTP\s0 server you could use .PP .Vb 1 \& net\-server HTTP .Ve .PP Or if you wanted to test out a \s-1CGI\s0 you are writing you could use .PP .Vb 1 \& net\-server HTTP \-\-app ../../mycgi.cgi .Ve .SH "ARGUMENTS" .IX Header "ARGUMENTS" There are at least five possible ways to pass arguments to Net::Server. They are \fIpassing to the new method\fR, \fIpassing on command line\fR, \fIpassing parameters to run\fR, \fIusing a conf file\fR, \&\fIreturning values in the default_values method\fR, or \fIconfiguring the values in post_configure_hook\fR. .PP The \f(CW\*(C`options\*(C'\fR method is used to determine which arguments the server will search for and can be used to extend the parsed parameters. Any arguments found from the command line, parameters passed to run, and arguments found in the conf_file will be matched against the keys of the options template. Any commandline parameters that do not match will be left in place and can be further processed by the server in the various hooks (by looking at \f(CW@ARGV\fR). Arguments passed to new will automatically win over any other options (this can be used if you would like to disallow a user passing in other arguments). .PP Arguments consist of key value pairs. On the commandline these pairs follow the \s-1POSIX\s0 fashion of \f(CW\*(C`\-\-key value\*(C'\fR or \f(CW\*(C`\-\-key=value\*(C'\fR, and also \&\f(CW\*(C`key=value\*(C'\fR. In the conf file the parameter passing can best be shown by the following regular expression: ($key,$val)=~/^(\ew+)\es+(\eS+?)\es+$/. Passing arguments to the run method is done as follows: \f(CW\*(C`<Net::Server\->run(key1 =\*(C'\fR 'val1')>>. Passing arguments via a prebuilt object can best be shown in the following code: .PP .Vb 1 \& #!/usr/bin/perl \-w \-T \& \& package MyPackage; \& use strict; \& use base qw(Net::Server); \& \& my $server = MyPackage\->new({ \& key1 => \*(Aqval1\*(Aq, \& }); \& \& $server\->run; .Ve .PP All five methods for passing arguments may be used at the same time. Once an argument has been set, it is not over written if another method passes the same argument. \f(CW\*(C`Net::Server\*(C'\fR will look for arguments in the following order: .PP .Vb 5 \& 1) Arguments passed to the C<new> method. \& 2) Arguments passed on command line. \& 3) Arguments passed to the C<run> method. \& 4) Arguments passed via a conf file. \& 5) Arguments set in the C<default_values> method. .Ve .PP Additionally the following hooks are available: .PP .Vb 4 \& 1) Arguments set in the configure_hook (occurs after new \& but before any of the other areas are checked). \& 2) Arguments set and validated in the post_configure_hook \& (occurs after all of the other areas are checked). .Ve .PP Each of these levels will override parameters of the same name specified in subsequent levels. For example, specifying \-\-setsid=0 on the command line will override a value of \*(L"setsid 1\*(R" in the conf file. .PP Note that the configure_hook method doesn't return values to set, but is there to allow for setting up configured values before the configure method is called. .PP Key/value pairs used by the server are removed by the configuration process so that server layers on top of \f(CW\*(C`Net::Server\*(C'\fR can pass and read their own parameters. .SH "ADDING CUSTOM ARGUMENTS" .IX Header "ADDING CUSTOM ARGUMENTS" It is possible to add in your own custom parameters to those parsed by Net::Server. The following code shows how this is done: .PP .Vb 4 \& sub options { \& my $self = shift; \& my $prop = $self\->{\*(Aqserver\*(Aq}; \& my $template = shift; \& \& # setup options in the parent classes \& $self\->SUPER::options($template); \& \& # add a single value option \& $prop\->{\*(Aqmy_option\*(Aq} ||= undef; \& $template\->{\*(Aqmy_option\*(Aq} = \e $prop\->{\*(Aqmy_option\*(Aq}; \& \& # add a multi value option \& $prop\->{\*(Aqan_arrayref_item\*(Aq} ||= []; \& $template\->{\*(Aqan_arrayref_item\*(Aq} = $prop\->{\*(Aqan_arrayref_item\*(Aq}; \& } .Ve .PP Overriding the \f(CW\*(C`options\*(C'\fR method allows for adding your own custom fields. A template hashref is passed in, that should then be modified to contain an of your custom fields. Fields which are intended to receive a single scalar value should have a reference to the destination scalar given. Fields which are intended to receive multiple values should reference the corresponding destination arrayref. .PP You are responsible for validating your custom options once they have been parsed. The post_configure_hook is a good place to do your validation. .PP Some emails have asked why we use this \*(L"template\*(R" method. The idea is that you are creating the the data structure to store the values in, and you are also creating a way to get the values into the data structure. The template is the way to get the values to the servers data structure. One of the possibilities (that probably isn't used that much) is that by letting you specify the mapping, you could build a nested data structure \- even though the passed in arguments are flat. It also allows you to setup aliases to your names. .PP For example, a basic structure might look like this: .PP .Vb 1 \& $prop = $self\->{\*(Aqserver\*(Aq} \& \& $prop\->{\*(Aqmy_custom_option\*(Aq} ||= undef; \& $prop\->{\*(Aqmy_custom_array\*(Aq} ||= []; \& \& $template = { \& my_custom_option => \e $prop\->{\*(Aqmy_custom_option\*(Aq}, \& mco => \e $prop\->{\*(Aqmy_custom_option\*(Aq}, # alias \& my_custom_array => $prop\->{\*(Aqmy_custom_array\*(Aq}, \& mca => $prop\->{\*(Aqmy_custom_array\*(Aq}, # an alias \& }; \& \& $template\->{\*(Aqmco2\*(Aq} = $template\->{\*(Aqmco\*(Aq}; # another way to alias .Ve .PP But you could also have more complex data: .PP .Vb 1 \& $prop = $self\->{\*(Aqserver\*(Aq}; \& \& $prop\->{\*(Aqone_layer\*(Aq} = { \& two_layer => [ \& undef, \& undef, \& ], \& }; \& \& $template = { \& param1 => \e $prop\->{\*(Aqone_layer\*(Aq}\->{\*(Aqtwo_layer\*(Aq}\->[0], \& param2 => \e $prop\->{\*(Aqone_layer\*(Aq}\->{\*(Aqtwo_layer\*(Aq}\->[1], \& }; .Ve .PP This is of course a contrived example \- but it does show that you can get the data from the flat passed in arguments to whatever type of structure you need \- with only a little bit of effort. .SH "DEFAULT ARGUMENTS FOR Net::Server" .IX Header "DEFAULT ARGUMENTS FOR Net::Server" The following arguments are available in the default \f(CW\*(C`Net::Server\*(C'\fR or \&\f(CW\*(C`Net::Server::Single\*(C'\fR modules. (Other personalities may use additional parameters and may optionally not use parameters from the base class.) .PP .Vb 2 \& Key Value Default \& conf_file "filename" undef \& \& log_level 0\-4 2 \& log_file (filename|Sys::Syslog \& |Log::Log4perl) undef \& \& port \ed+ 20203 \& host "host" "*" \& ipv (4|6|*) * \& proto (tcp|udp|unix) "tcp" \& listen \ed+ SOMAXCONN \& \& ## syslog parameters (if log_file eq Sys::Syslog) \& syslog_logsock (native|unix|inet|udp \& |tcp|stream|console) unix (on Sys::Syslog < 0.15) \& syslog_ident "identity" "net_server" \& syslog_logopt (cons|ndelay|nowait|pid) pid \& syslog_facility \ew+ daemon \& \& reverse_lookups 1 undef \& allow /regex/ none \& deny /regex/ none \& cidr_allow CIDR none \& cidr_deny CIDR none \& \& ## daemonization parameters \& pid_file "filename" undef \& chroot "directory" undef \& user (uid|username) "nobody" \& group (gid|group) "nobody" \& background 1 undef \& setsid 1 undef \& \& no_close_by_child (1|undef) undef \& \& ## See Net::Server::Proto::(TCP|UDP|UNIX|SSL|SSLeay|etc) \& ## for more sample parameters. .Ve .IP "conf_file" 4 .IX Item "conf_file" Filename from which to read additional key value pair arguments for starting the server. Default is undef. .Sp There are two ways that you can specify a default location for a conf_file. The first is to pass the default value to the run method as in: .Sp .Vb 3 \& MyServer\->run({ \& conf_file => \*(Aq/etc/my_server.conf\*(Aq, \& }); .Ve .Sp If the end user passes in \-\-conf_file=/etc/their_server.conf then the value will be overridden. .Sp The second way to do this was added in the 0.96 version. It uses the default_values method as in: .Sp .Vb 5 \& sub default_values { \& return { \& conf_file => \*(Aq/etc/my_server.conf\*(Aq, \& } \& } .Ve .Sp This method has the advantage of also being able to be overridden in the run method. .Sp If you do not want the user to be able to specify a conf_file at all, you can pass conf_file to the new method when creating your object: .Sp .Vb 3 \& MyServer\->new({ \& conf_file => \*(Aq/etc/my_server.conf\*(Aq, \& })\->run; .Ve .Sp If passed this way, the value passed to new will \*(L"win\*(R" over any of the other passed in values. .IP "log_level" 4 .IX Item "log_level" Ranges from 0 to 4 in level. Specifies what level of error will be logged. \*(L"O\*(R" means logging is off. \*(L"4\*(R" means very verbose. These levels should be able to correlate to syslog levels. Default is 2. These levels correlate to syslog levels as defined by the following key/value pairs: 0=>'err', 1=>'warning', 2=>'notice', 3=>'info', 4=>'debug'. .IP "log_file" 4 .IX Item "log_file" Name of log file or log subsystem to be written to. If no name is given and the write_to_log_hook is not overridden, log goes to \s-1STDERR. \s0 Default is undef. .Sp The log_file may also be the name of a Net::Server pluggable logging class. Net::Server is packaged with Sys::Syslog and Log::Log4perl. If the log_file looks like a module name, it will have \&\*(L"Net::Server::Log::\*(R" added to the front and it will then be required. The package should provide an \f(CW\*(C`initialize\*(C'\fR class method that returns a single function which will be used for logging. This returned function will be passed log_level, and message. .Sp If the magic name \*(L"Sys::Syslog\*(R" is used, all logging will take place via the Net::Server::Log::Sys::Syslog module. If syslog is used the parameters \f(CW\*(C`syslog_logsock\*(C'\fR, \f(CW\*(C`syslog_ident\*(C'\fR, and \&\f(CW\*(C`syslog_logopt\*(C'\fR,and \f(CW\*(C`syslog_facility\*(C'\fR may also be defined. See Net::Server::Log::Sys::Syslog. .Sp If the magic name \*(L"Log::Log4perl\*(R" is used, all logging will be directed to the Log4perl system. If used, the \f(CW\*(C`log4perl_conf\*(C'\fR, \&\f(CW\*(C`log4perl_poll\*(C'\fR, \f(CW\*(C`log4perl_logger\*(C'\fR may also be defined. See Net::Server::Log::Log::Log4per. .Sp If a \f(CW\*(C`log_file\*(C'\fR is given or if \f(CW\*(C`setsid\*(C'\fR is set, \s-1STDIN\s0 and \s-1STDOUT\s0 will automatically be opened to /dev/null and \s-1STDERR\s0 will be opened to \&\s-1STDOUT. \s0 This will prevent any output from ending up at the terminal. .IP "pid_file" 4 .IX Item "pid_file" Filename to store pid of parent process. Generally applies only to forking servers. Default is none (undef). .IP "port" 4 .IX Item "port" See Net::Server::Proto for further examples of configuration. .Sp Local port/socket on which to bind. If it is a low port, the process must start as root. If multiple ports are given, all will be bound at server startup. May be of the form \f(CW\*(C`host:port/proto\*(C'\fR, \&\f(CW\*(C`host:port/proto/ipv\*(C'\fR, \f(CW\*(C`host:port\*(C'\fR, \f(CW\*(C`port/proto\*(C'\fR, or \f(CW\*(C`port\*(C'\fR, where \&\fIhost\fR represents a hostname residing on the local box, where \fIport\fR represents either the number of the port (eg. \*(L"80\*(R") or the service designation (eg. \*(L"http\*(R"), where \fIipv\fR represents the \s-1IP\s0 protocol version (IPv4 or IPv6 or IPv*) and where \fIproto\fR represents the protocol to be used. See Net::Server::Proto. The following are some valid port strings: .Sp .Vb 9 \& 20203 # port only \& localhost:20203 # host and port \& localhost:http # localhost bound to port 80 \& localhost:20203/tcp # host, port, protocol \& localhost:20203/tcp/IPv* # host, port, protocol and family \& localhost, 20203, tcp, IPv* # same \& localhost | 20203 | tcp | IPv* # same \& localhost:20203/IPv* # bind any configured interfaces for IPv4 or 6 (default) \& localhost:20203/IPv4/IPv6 # bind localhost on IPv4 and 6 (fails if it cannot do both) \& \& *:20203 # bind all local interfaces .Ve .Sp Additionally, when passed in the code (non-commandline, and non-config), the port may be passed as a hashref or array hashrefs of information: .Sp .Vb 6 \& port => { \& host => \*(Aqlocalhost\*(Aq, \& port => \*(Aq20203\*(Aq, \& ipv => 6, # IPv6 only \& proto => \*(Aqudp\*(Aq, # UDP protocol \& } \& \& port => [{ \& host => \*(Aq*\*(Aq, \& port => \*(Aq20203\*(Aq, \& ipv => 4, # IPv4 only \& proto => \*(Aqtcp\*(Aq, # (default) \& }, { \& host => \*(Aqlocalhost\*(Aq, \& port => \*(Aq20204\*(Aq, \& ipv => \*(Aq*\*(Aq, # default \- all IPv4 and IPv6 interfaces tied to localhost \& proto => \*(Aqssleay\*(Aq, # or ssl \- Using SSL \& }], .Ve .Sp An explicit \fIhost\fR given in a port specification overrides a default binding address (a \f(CW\*(C`host\*(C'\fR setting, see below). The \fIhost\fR part may be enclosed in square brackets, but when it is a numerical IPv6 address it \fBshould\fR be enclosed in square brackets to avoid ambiguity in parsing a port number, e.g.: \*(L"[::1]:80\*(R". However you could also use pipes, white space, or commas to separate these. Note that host and port number must come first. .Sp If the protocol is not specified, \fIproto\fR will default to the \&\f(CW\*(C`proto\*(C'\fR specified in the arguments. If \f(CW\*(C`proto\*(C'\fR is not specified there it will default to \*(L"tcp\*(R". If \fIhost\fR is not specified, \fIhost\fR will default to \f(CW\*(C`host\*(C'\fR specified in the arguments. If \f(CW\*(C`host\*(C'\fR is not specified there it will default to \*(L"*\*(R". Default port is 20203. Configuration passed to new or run may be either a scalar containing a single port number or an arrayref of ports. If \f(CW\*(C`ipv\*(C'\fR is not specified it will default to \*(L"*\*(R" (Any resolved addresses under IPv4 or IPv6). .Sp If you are working with unix sockets, you may also specify \&\f(CW\*(C`socket_file|unix\*(C'\fR or \f(CW\*(C`socket_file|type|unix\*(C'\fR where type is \s-1SOCK_DGRAM\s0 or \s-1SOCK_STREAM.\s0 .Sp On systems that support it, a port value of 0 may be used to ask the \s-1OS\s0 to auto-assign a port. The value of the auto-assigned port will be stored in the NS_port property of the Net::Server::Proto::TCP object and is also available in the sockport method. When the server is processing a request, the \f(CW$self\fR\->{server}\->{sockport} property contains the port that was connected through. .IP "host" 4 .IX Item "host" Local host or addr upon which to bind port. If a value of '*' is given, the server will bind that port on all available addresses on the box. The \f(CW\*(C`host\*(C'\fR argument provides a default local host address if the \f(CW\*(C`port\*(C'\fR argument omits a host specification. See Net::Server::Proto. See IO::Socket. Configuration passed to new or run may be either a scalar containing a single host or an arrayref of hosts \- if the hosts array is shorter than the ports array, the last host entry will be used to augment the hosts arrary to the size of the ports array. .Sp If an IPv4 address is passed, an IPv4 socket will be created. If an IPv6 address is passed, an IPv6 socket will be created. If a hostname is given, Net::Server will look at the value of ipv (default IPv4) to determine which type of socket to create. Optionally the ipv specification can be passed as part of the hostname. .Sp .Vb 1 \& host => "127.0.0.1", # an IPv4 address \& \& host => "::1", # an IPv6 address \& \& host => \*(Aqlocalhost\*(Aq, # addresses matched by localhost (default any IPv4 and/or IPv6) \& \& host => \*(Aqlocalhost/IPv*\*(Aq, # same \& \& ipv => 6, \& host => \*(Aqlocalhost\*(Aq, # addresses matched by localhost (IPv6) \& \& ipv => 4, \& host => \*(Aqlocalhost\*(Aq, # addresses matched by localhost (IPv4) \& \& ipv => \*(AqIPv4 IPv6\*(Aq, \& host => \*(Aqlocalhost\*(Aq, # addresses matched by localhost (requires IPv6 and IPv4) \& \& host => \*(Aq*\*(Aq, # any local interfaces (any IPv6 or IPv4) \& \& host => \*(Aq*/IPv*\*(Aq, # same (any IPv6 or IPv4) \& \& ipv => 4, \& host => \*(Aq*\*(Aq, # any local IPv4 interfaces interfaces .Ve .IP "proto" 4 .IX Item "proto" See Net::Server::Proto. Protocol to use when binding ports. See IO::Socket. As of release 2.0, Net::Server supports tcp, udp, and unix, unixdgram, ssl, and ssleay. Other types will need to be added later (or custom modules extending the Net::Server::Proto class may be used). Configuration passed to new or run may be either a scalar containing a single proto or an arrayref of protos \- if the protos array is shorter than the ports array, the last proto entry will be used to augment the protos arrary to the size of the ports array. .Sp Additionally the proto may also contain the ipv specification. .IP "ipv (IPv4 and IPv6)" 4 .IX Item "ipv (IPv4 and IPv6)" See Net::Server::Proto. .Sp IPv6 is now available under Net::Server. It will be used automatically if an IPv6 address is passed, or if the ipv is set explicitly to IPv6, or if ipv is left as the default value of IPv*. This is a significant change from version 2.004 and earlier where the default value was IPv4. However, the previous behavior led to confusion on IPv6 only hosts, and on hosts that only had IPv6 entries for a local hostname. Trying to pass an IPv4 address when ipv is set to 6 (only 6 \- not * or 4) will result in an error. .Sp .Vb 2 \& localhost:20203 # will use IPv6 if there is a corresponding entry for localhost \& # it will also use IPv4 if there is a corresponding v4 entry for localhost \& \& localhost:20203:IPv* # same (default) \& \& localhost:20203:IPv6 # will use IPv6 \& \& [::1]:20203 # will use IPv6 (IPv6 style address) \& \& localhost:20203:IPv4 # will use IPv4 \& \& 127.0.0.1:20203 # will use IPv4 (IPv4 style address \& \& localhost:20203:IPv4:IPv6 # will bind to both v4 and v6 \- fails otherwise \& \& # or as a hashref as \& port => { \& host => "localhost", \& ipv => 6, # only binds IPv6 \& } \& \& port => { \& host => "localhost", \& ipv => 4, # only binds IPv4 \& } \& \& port => { \& host => "::1", \& ipv => "IPv6", # same as passing "6" \& } \& \& port => { \& host => "localhost/IPv*", # any IPv4 or IPv6 \& } \& \& port => { \& host => "localhost IPv4 IPv6", # must create both \& } .Ve .Sp In many proposed Net::Server solutions, IPv* was enabled by default. For versions 2.000 through 2.004, the previous default of IPv4 was used. We have attempted to make it easy to set IPv4, IPv6, or IPv*. If you do not want or need IPv6, simply set ipv to 4, pass IPv4 along in the port specification, set \f(CW$ENV\fR{'\s-1IPV\s0'}=4; before running the server, or uninstall IO::Socket::INET6. .Sp On my local box the following command results in the following output: .Sp .Vb 1 \& perl \-e \*(Aquse base qw(Net::Server); main\->run(host => "localhost")\*(Aq \& \& Resolved [localhost]:20203 to [::1]:20203, IPv6 \& Resolved [localhost]:20203 to [127.0.0.1]:20203, IPv4 \& Binding to TCP port 20203 on host ::1 with IPv6 \& Binding to TCP port 20203 on host 127.0.0.1 with IPv4 .Ve .Sp My local box has IPv6 enabled and there are entries for localhost on both IPv6 ::1 and IPv4 127.0.0.1. I could also choose to explicitly bind ports rather than depending upon ipv => \*(L"*\*(R" to resolve them for me as in the following: .Sp .Vb 1 \& perl \-e \*(Aquse base qw(Net::Server); main\->run(port => [20203,20203], host => "localhost", ipv => [4,6])\*(Aq \& \& Binding to TCP port 20203 on host localhost with IPv4 \& Binding to TCP port 20203 on host localhost with IPv6 .Ve .Sp There is a special case of using host => \*(L"*\*(R" as well as ipv => \*(L"*\*(R". The Net::Server::Proto::_bindv6only method is used to check the system setting for \f(CW\*(C`sysctl \-n net.ipv6.bindv6only\*(C'\fR (or net.inet6.ip6.v6only). If this setting is false, then an IPv6 socket will listen for the corresponding IPv4 address. For example the address [::] (IPv6 equivalent of \s-1INADDR_ANY\s0) will also listen for 0.0.0.0. The address ::FFFF:127.0.0.1 (IPv6) would also listen to 127.0.0.1 (IPv4). In this case, only one socket will be created because it will handle both cases (an error is returned if an attempt is made to listen to both addresses when bindv6only is false). .Sp However, if net.ipv6.bindv6only (or equivalent) is true, then a hostname (such as *) resolving to both a IPv4 entry as well as an IPv6 will result in both an IPv4 socket as well as an IPv6 socket. .Sp On my linux box which defaults to net.ipv6.bindv6only=0, the following is output. .Sp .Vb 1 \& perl \-e \*(Aquse base qw(Net::Server); main\->run(host => "*")\*(Aq \& \& Resolved [*]:8080 to [::]:8080, IPv6 \& Not including resolved host [0.0.0.0] IPv4 because it will be handled by [::] IPv6 \& Binding to TCP port 8080 on host :: with IPv6 .Ve .Sp If I issue a \f(CW\*(C`sudo /sbin/sysctl \-w net.ipv6.bindv6only=1\*(C'\fR, the following is output. .Sp .Vb 1 \& perl \-e \*(Aquse base qw(Net::Server); main\->run(host => "*")\*(Aq \& \& Resolved [*]:8080 to [0.0.0.0]:8080, IPv4 \& Resolved [*]:8080 to [::]:8080, IPv6 \& Binding to TCP port 8080 on host 0.0.0.0 with IPv4 \& Binding to TCP port 8080 on host :: with IPv6 .Ve .Sp \&\s-1BSD\s0 differs from linux and generally defaults to net.inet6.ip6.v6only=0. If it cannot be determined on your \s-1OS,\s0 it will default to false and the log message will change from \*(L"it will be handled\*(R" to \*(L"it should be handled\*(R" (if you have a non-resource intensive way to check on your platform, feel free to email me). Be sure to check the logs as you test your server to make sure you have bound the ports you desire. You can always pass in individual explicit IPv4 and IPv6 port specifications if you need. For example, if your system has both IPv4 and IPv6 interfaces but you'd only like to bind to IPv6 entries, then you should use a hostname of [::] instead of [*]. .Sp If bindv6only (or equivalent) is false, and you receive an IPv4 connection on a bound IPv6 port, the textual representation of the peer's IPv4 address will typically be in a form of an IPv4\-mapped IPv6 addresses, e.g. \*(L"::FFFF:127.0.0.1\*(R" . .Sp The ipv parameter was chosen because it does not conflict with any other existing usage, it is very similar to ipv4 or ipv6, it allows for user code to not need to know about Socket::AF_INET or Socket6::AF_INET6 or Socket::AF_UNSPEC, and it is short. .IP "listen" 4 .IX Item "listen" See IO::Socket. Not used with udp protocol (or \s-1UNIX SOCK_DGRAM\s0). .IP "reverse_lookups" 4 .IX Item "reverse_lookups" Specify whether to lookup the hostname of the connected \s-1IP.\s0 Information is cached in server object under \f(CW\*(C`peerhost\*(C'\fR property. Default is to not use reverse_lookups (undef). .IP "allow/deny" 4 .IX Item "allow/deny" May be specified multiple times. Contains regex to compare to incoming peeraddr or peerhost (if reverse_lookups has been enabled). If allow or deny options are given, the incoming client must match an allow and not match a deny or the client connection will be closed. Defaults to empty array refs. .IP "cidr_allow/cidr_deny" 4 .IX Item "cidr_allow/cidr_deny" May be specified multiple times. Contains a \s-1CIDR\s0 block to compare to incoming peeraddr. If cidr_allow or cidr_deny options are given, the incoming client must match a cidr_allow and not match a cidr_deny or the client connection will be closed. Defaults to empty array refs. .IP "chroot" 4 .IX Item "chroot" Directory to chroot to after bind process has taken place and the server is still running as root. Defaults to undef. .IP "user" 4 .IX Item "user" Userid or username to become after the bind process has occured. Defaults to \*(L"nobody.\*(R" If you would like the server to run as root, you will have to specify \f(CW\*(C`user\*(C'\fR equal to \*(L"root\*(R". .IP "group" 4 .IX Item "group" Groupid or groupname to become after the bind process has occured. Defaults to \*(L"nobody.\*(R" If you would like the server to run as root, you will have to specify \f(CW\*(C`group\*(C'\fR equal to \*(L"root\*(R". .IP "background" 4 .IX Item "background" Specifies whether or not the server should fork after the bind method to release itself from the command line. Defaults to undef. Process will also background if \f(CW\*(C`setsid\*(C'\fR is set. .IP "setsid" 4 .IX Item "setsid" Specifies whether or not the server should fork after the bind method to release itself from the command line and then run the \&\f(CW\*(C`POSIX::setsid()\*(C'\fR command to truly daemonize. Defaults to undef. If a \f(CW\*(C`log_file\*(C'\fR is given or if \f(CW\*(C`setsid\*(C'\fR is set, \s-1STDIN\s0 and \s-1STDOUT\s0 will automatically be opened to /dev/null and \s-1STDERR\s0 will be opened to \&\s-1STDOUT. \s0 This will prevent any output from ending up at the terminal. .IP "no_close_by_child" 4 .IX Item "no_close_by_child" Boolean. Specifies whether or not a forked child process has permission or not to shutdown the entire server process. If set to 1, the child may \s-1NOT\s0 signal the parent to shutdown all children. Default is undef (not set). .IP "no_client_stdout" 4 .IX Item "no_client_stdout" Boolean. Default undef (not set). Specifies that \s-1STDIN\s0 and \s-1STDOUT\s0 should not be opened on the client handle once a connection has been accepted. By default the Net::Server will open \s-1STDIN\s0 and \s-1STDOUT\s0 on the client socket making it easier for many types of scripts to read directly from and write directly to the socket using normal print and read methods. Disabling this is useful on clients that may be opening their own connections to \s-1STDIN\s0 and \s-1STDOUT.\s0 .Sp This option has no affect on \s-1STDIN\s0 and \s-1STDOUT\s0 which has a magic client property that is tied to the already open \s-1STDIN\s0 and \s-1STDOUT.\s0 .IP "leave_children_open_on_hup" 4 .IX Item "leave_children_open_on_hup" Boolean. Default undef (not set). If set, the parent will not attempt to close child processes if the parent receives a \s-1SIG HUP.\s0 The parent will rebind the the open port and begin tracking a fresh set of children. .Sp Children of a Fork server will exit after their current request. Children of a Prefork type server will finish the current request and then exit. .Sp Note \- the newly restarted parent will start up a fresh set of servers on fork servers. The new parent will attempt to keep track of the children from the former parent but custom communication channels (open pipes from the child to the old parent) will no longer be available to the old child processes. New child processes will still connect properly to the new parent. .IP "sig_passthrough" 4 .IX Item "sig_passthrough" Default none. Allow for passing requested signals through to children. Takes a single signal name, a comma separated list of names, or an arrayref of signal names. It first sends the signals to the children before calling any currently registered signal by that name. .IP "tie_client_stdout" 4 .IX Item "tie_client_stdout" Default undef. If set will use Net::Server::TiedHandle tied interface for \s-1STDIN\s0 and \s-1STDOUT. \s0 This interface allows \s-1SSL\s0 and \s-1SSLEAY\s0 to work. It also allows for intercepting read and write via the tied_stdin_callback and tied_stdout_callback. .IP "tied_stdin_callback" 4 .IX Item "tied_stdin_callback" Default undef. Called during a read of \s-1STDIN\s0 data if tie_client_stdout has been set, or if the client handle's tie_stdout method returns true. It is passed the client connection, the name of the method that would be called, and the arguments that are being passed. The callback is then responsible for calling that method on the handle or for performing some other input operation. .IP "tied_stdout_callback" 4 .IX Item "tied_stdout_callback" Default undef. Called during a write of data to \s-1STDOUT\s0 if tie_client_stdout has been set, or if the client handle's tie_stdout method returns true. It is passed the client connection, the name of the method that would be called, and the arguments that are being passed. The callback is then responsible for calling that method on the handle or for performing some other output operation. .SH "PROPERTIES" .IX Header "PROPERTIES" All of the \f(CW\*(C`ARGUMENTS\*(C'\fR listed above become properties of the server object under the same name. These properties, as well as other internal properties, are available during hooks and other method calls. .PP The structure of a Net::Server object is shown below: .PP .Vb 6 \& $self = bless({ \& server => { \& key1 => \*(Aqval1\*(Aq, \& # more key/vals \& }, \& }, \*(AqNet::Server\*(Aq); .Ve .PP This structure was chosen so that all server related properties are grouped under a single key of the object hashref. This is so that other objects could layer on top of the Net::Server object class and still have a fairly clean namespace in the hashref. .PP You may get and set properties in two ways. The suggested way is to access properties directly via .PP .Vb 1 \& my $val = $self\->{server}\->{key1}; .Ve .PP Accessing the properties directly will speed the server process \- though some would deem this as bad style. A second way has been provided for object oriented types who believe in methods. The second way consists of the following methods: .PP .Vb 2 \& my $val = $self\->get_property( \*(Aqkey1\*(Aq ); \& my $self\->set_property( key1 => \*(Aqval1\*(Aq ); .Ve .PP Properties are allowed to be changed at any time with caution (please do not undef the sock property or you will close the client connection). .SH "CONFIGURATION FILE" .IX Header "CONFIGURATION FILE" \&\f(CW\*(C`Net::Server\*(C'\fR allows for the use of a configuration file to read in server parameters. The format of this conf file is simple key value pairs. Comments and blank lines are ignored. .PP .Vb 1 \& #\-\-\-\-\-\-\-\-\-\-\-\-\-\- file test.conf \-\-\-\-\-\-\-\-\-\-\-\-\-\- \& \& ### user and group to become \& user somebody \& group everybody \& \& # logging ? \& log_file /var/log/server.log \& log_level 3 \& pid_file /tmp/server.pid \& \& # optional syslog directive \& # used in place of log_file above \& #log_file Sys::Syslog \& #syslog_logsock unix \& #syslog_ident myserver \& #syslog_logopt pid|cons \& \& # access control \& allow .+\e.(net|com) \& allow domain\e.com \& deny a.+ \& cidr_allow 127.0.0.0/8 \& cidr_allow 192.0.2.0/24 \& cidr_deny 192.0.2.4/30 \& \& # background the process? \& background 1 \& \& # ports to bind (this should bind \& # 127.0.0.1:20205 on IPv6 and \& # localhost:20204 on IPv4) \& # See Net::Server::Proto \& host 127.0.0.1 \& ipv IPv6 \& port localhost:20204/IPv4 \& port 20205 \& \& # reverse lookups ? \& # reverse_lookups on \& \& #\-\-\-\-\-\-\-\-\-\-\-\-\-\- file test.conf \-\-\-\-\-\-\-\-\-\-\-\-\-\- .Ve .SH "PROCESS FLOW" .IX Header "PROCESS FLOW" The process flow is written in an open, easy to override, easy to hook, fashion. The basic flow is shown below. This is the flow of the \f(CW\*(C`$self\->run\*(C'\fR method. .PP .Vb 1 \& $self\->configure_hook; \& \& $self\->configure(@_); \& \& $self\->post_configure; \& \& $self\->post_configure_hook; \& \& $self\->pre_bind; \& \& $self\->bind; \& \& $self\->post_bind_hook; \& \& $self\->post_bind; \& \& $self\->pre_loop_hook; \& \& $self\->loop; \& \& ### routines inside a standard $self\->loop \& # $self\->accept; \& # $self\->run_client_connection; \& # $self\->done; \& \& $self\->pre_server_close_hook; \& \& $self\->server_close; .Ve .PP The server then exits. .PP During the client processing phase (\f(CW\*(C`$self\->run_client_connection\*(C'\fR), the following represents the program flow: .PP .Vb 1 \& $self\->post_accept; \& \& $self\->get_client_info; \& \& $self\->post_accept_hook; \& \& if ($self\->allow_deny \& && $self\->allow_deny_hook) { \& \& $self\->process_request; \& \& } else { \& \& $self\->request_denied_hook; \& \& } \& \& $self\->post_process_request_hook; \& \& $self\->post_process_request; \& \& $self\->post_client_connection_hook; .Ve .PP The process then loops and waits for the next connection. For a more in depth discussion, please read the code. .PP During the server shutdown phase (\f(CW\*(C`$self\->server_close\*(C'\fR), the following represents the program flow: .PP .Vb 1 \& $self\->close_children; # if any \& \& $self\->post_child_cleanup_hook; \& \& if (Restarting server) { \& $self\->restart_close_hook(); \& $self\->hup_server; \& } \& \& $self\->shutdown_sockets; \& \& $self\->server_exit; .Ve .SH "MAIN SERVER METHODS" .IX Header "MAIN SERVER METHODS" .ie n .IP """$self\->run""" 4 .el .IP "\f(CW$self\->run\fR" 4 .IX Item "$self->run" This method incorporates the main process flow. This flow is listed above. .Sp The method run may be called in any of the following ways. .Sp .Vb 1 \& MyPackage\->run(port => 20201); \& \& MyPackage\->new({port => 20201})\->run; \& \& my $obj = bless {server=>{port => 20201}}, \*(AqMyPackage\*(Aq; \& $obj\->run; .Ve .Sp The \->run method should typically be the last method called in a server start script (the server will exit at the end of the \->run method). .ie n .IP """$self\->configure""" 4 .el .IP "\f(CW$self\->configure\fR" 4 .IX Item "$self->configure" This method attempts to read configurations from the commandline, from the run method call, or from a specified conf_file (the conf_file may be specified by passed in parameters, or in the default_values). All of the configured parameters are then stored in the {\*(L"server\*(R"} property of the Server object. .ie n .IP """$self\->post_configure""" 4 .el .IP "\f(CW$self\->post_configure\fR" 4 .IX Item "$self->post_configure" The post_configure hook begins the startup of the server. During this method running server instances are checked for, pid_files are created, log_files are created, Sys::Syslog is initialized (as needed), process backgrounding occurs and the server closes \s-1STDIN\s0 and \&\s-1STDOUT \s0(as needed). .ie n .IP """$self\->pre_bind""" 4 .el .IP "\f(CW$self\->pre_bind\fR" 4 .IX Item "$self->pre_bind" This method is used to initialize all of the socket objects used by the server. .ie n .IP """$self\->bind""" 4 .el .IP "\f(CW$self\->bind\fR" 4 .IX Item "$self->bind" This method actually binds to the inialized sockets (or rebinds if the server has been HUPed). .ie n .IP """$self\->post_bind""" 4 .el .IP "\f(CW$self\->post_bind\fR" 4 .IX Item "$self->post_bind" During this method priveleges are dropped. The \s-1INT, TERM,\s0 and \s-1QUIT\s0 signals are set to run server_close. Sig \s-1PIPE\s0 is set to \s-1IGNORE. \s0 Sig \&\s-1CHLD\s0 is set to sig_chld. And sig \s-1HUP\s0 is set to call sig_hup. .Sp Under the Fork, PreFork, and PreFork simple personalities, these signals are registered using Net::Server::SIG to allow for safe signal handling. .ie n .IP """$self\->loop""" 4 .el .IP "\f(CW$self\->loop\fR" 4 .IX Item "$self->loop" During this phase, the server accepts incoming connections. The behavior of how the accepting occurs and if a child process handles the connection is controlled by what type of Net::Server personality the server is using. .Sp Net::Server and Net::Server single accept only one connection at a time. .Sp Net::Server::INET runs one connection and then exits (for use by inetd or xinetd daemons). .Sp Net::Server::MultiPlex allows for one process to simultaneously handle multiple connections (but requires rewriting the process_request code to operate in a more \*(L"packet-like\*(R" manner). .Sp Net::Server::Fork forks off a new child process for each incoming connection. .Sp Net::Server::PreForkSimple starts up a fixed number of processes that all accept on incoming connections. .Sp Net::Server::PreFork starts up a base number of child processes which all accept on incoming connections. The server throttles the number of processes running depending upon the number of requests coming in (similar to concept to how Apache controls its child processes in a PreFork server). .Sp Read the documentation for each of the types for more information. .ie n .IP """$self\->server_close""" 4 .el .IP "\f(CW$self\->server_close\fR" 4 .IX Item "$self->server_close" This method is called once the server has been signaled to end, or signaled for the server to restart (via \s-1HUP\s0), or the loop method has been exited. .Sp This method takes care of cleaning up any remaining child processes, setting appropriate flags on sockets (for HUPing), closing up logging, and then closing open sockets. .Sp Can optionally be passed an exit value that will be passed to the server_exit call. .ie n .IP """$self\->server_exit""" 4 .el .IP "\f(CW$self\->server_exit\fR" 4 .IX Item "$self->server_exit" This method is called at the end of server_close. It calls exit, but may be overridden to do other items. At this point all services should be shut down. .Sp Can optionally be passed an exit value that will be passed to the exit call. .SH "MAIN CLIENT CONNECTION METHODS" .IX Header "MAIN CLIENT CONNECTION METHODS" .ie n .IP """$self\->run_client_connection""" 4 .el .IP "\f(CW$self\->run_client_connection\fR" 4 .IX Item "$self->run_client_connection" This method is run after the server has accepted and received a client connection. The full process flow is listed above under \s-1PROCESS FLOWS. \s0 This method takes care of handling each client connection. .ie n .IP """$self\->post_accept""" 4 .el .IP "\f(CW$self\->post_accept\fR" 4 .IX Item "$self->post_accept" This method opens \s-1STDIN\s0 and \s-1STDOUT\s0 to the client socket. This allows any of the methods during the run_client_connection phase to print directly to and read directly from the client socket. .ie n .IP """$self\->get_client_info""" 4 .el .IP "\f(CW$self\->get_client_info\fR" 4 .IX Item "$self->get_client_info" This method looks up information about the client connection such as ip address, socket type, and hostname (as needed). .ie n .IP """$self\->allow_deny""" 4 .el .IP "\f(CW$self\->allow_deny\fR" 4 .IX Item "$self->allow_deny" This method uses the rules defined in the allow and deny configuration parameters to determine if the ip address should be accepted. .ie n .IP """$self\->process_request""" 4 .el .IP "\f(CW$self\->process_request\fR" 4 .IX Item "$self->process_request" This method is intended to handle all of the client communication. At this point \s-1STDIN\s0 and \s-1STDOUT\s0 are opened to the client, the ip address has been verified. The server can then interact with the client connection according to whatever \s-1API\s0 or protocol the server is implementing. Note that the stub implementation uses \s-1STDIN\s0 and \s-1STDOUT\s0 and will not work if the no_client_stdout flag is set. .Sp This is the main method to override. .Sp The default method implements a simple echo server that will repeat whatever is sent. It will quit the child if \*(L"quit\*(R" is sent, and will exit the server if \*(L"exit\*(R" is sent. .Sp As of version 2.000, the client handle is passed as an argument. .ie n .IP """$self\->post_process_request""" 4 .el .IP "\f(CW$self\->post_process_request\fR" 4 .IX Item "$self->post_process_request" This method is used to clean up the client connection and to handle any parent/child accounting for the forking servers. .SH "HOOKS" .IX Header "HOOKS" \&\f(CW\*(C`Net::Server\*(C'\fR provides a number of \*(L"hooks\*(R" allowing for servers layered on top of \f(CW\*(C`Net::Server\*(C'\fR to respond at different levels of execution without having to \*(L"\s-1SUPER\*(R"\s0 class the main built-in methods. The placement of the hooks can be seen in the \s-1PROCESS FLOW\s0 section. .PP Almost all of the default hook methods do nothing. To use a hook you simply need to override the method in your subclass. For example to add your own post_configure_hook you could do something like the following: .PP .Vb 1 \& package MyServer; \& \& sub post_configure_hook { \& my $self = shift; \& my $prop = $self\->{\*(Aqserver\*(Aq}; \& \& # do some validation here \& } .Ve .PP The following describes the hooks available in the plain Net::Server class (other flavors such as Fork or PreFork have additional hooks). .ie n .IP """$self\->configure_hook()""" 4 .el .IP "\f(CW$self\->configure_hook()\fR" 4 .IX Item "$self->configure_hook()" This hook takes place immediately after the \f(CW\*(C`\->run()\*(C'\fR method is called. This hook allows for setting up the object before any built in configuration takes place. This allows for custom configurability. .ie n .IP """$self\->post_configure_hook()""" 4 .el .IP "\f(CW$self\->post_configure_hook()\fR" 4 .IX Item "$self->post_configure_hook()" This hook occurs just after the reading of configuration parameters and initiation of logging and pid_file creation. It also occurs before the \f(CW\*(C`\->pre_bind()\*(C'\fR and \f(CW\*(C`\->bind()\*(C'\fR methods are called. This hook allows for verifying configuration parameters. .ie n .IP """$self\->post_bind_hook()""" 4 .el .IP "\f(CW$self\->post_bind_hook()\fR" 4 .IX Item "$self->post_bind_hook()" This hook occurs just after the bind process and just before any chrooting, change of user, or change of group occurs. At this point the process will still be running as the user who started the server. .ie n .IP """$self\->pre_loop_hook()""" 4 .el .IP "\f(CW$self\->pre_loop_hook()\fR" 4 .IX Item "$self->pre_loop_hook()" This hook occurs after chroot, change of user, and change of group has occured. It allows for preparation before looping begins. .ie n .IP """$self\->can_read_hook()""" 4 .el .IP "\f(CW$self\->can_read_hook()\fR" 4 .IX Item "$self->can_read_hook()" This hook occurs after a socket becomes readible on an accept_multi_port request (accept_multi_port is used if there are multiple bound ports to accept on, or if the \*(L"multi_port\*(R" configuration parameter is set to true). This hook is intended to allow for processing of arbitrary handles added to the IO::Select used for the accept_multi_port. These handles could be added during the post_bind_hook. No internal support is added for processing these handles or adding them to the IO::Socket. Care must be used in how much occurs during the can_read_hook as a long response time will result in the server being susceptible to \s-1DOS\s0 attacks. A return value of true indicates that the Server should not pass the readible handle on to the post_accept and process_request phases. .Sp It is generally suggested that other avenues be pursued for sending messages via sockets not created by the Net::Server. .ie n .IP """$self\->post_accept_hook()""" 4 .el .IP "\f(CW$self\->post_accept_hook()\fR" 4 .IX Item "$self->post_accept_hook()" This hook occurs after a client has connected to the server. At this point \s-1STDIN\s0 and \s-1STDOUT\s0 are mapped to the client socket. This hook occurs before the processing of the request. .ie n .IP """$self\->allow_deny_hook()""" 4 .el .IP "\f(CW$self\->allow_deny_hook()\fR" 4 .IX Item "$self->allow_deny_hook()" This hook allows for the checking of ip and host information beyond the \f(CW\*(C`$self\->allow_deny()\*(C'\fR routine. If this hook returns 1, the client request will be processed, otherwise, the request will be denied processing. .Sp As of version 2.000, the client connection is passed as an argument. .ie n .IP """$self\->request_denied_hook()""" 4 .el .IP "\f(CW$self\->request_denied_hook()\fR" 4 .IX Item "$self->request_denied_hook()" This hook occurs if either the \f(CW\*(C`$self\->allow_deny()\*(C'\fR or \&\f(CW\*(C`$self\->allow_deny_hook()\*(C'\fR have taken place. .ie n .IP """$self\->post_process_request_hook()""" 4 .el .IP "\f(CW$self\->post_process_request_hook()\fR" 4 .IX Item "$self->post_process_request_hook()" This hook occurs after the processing of the request, but before the client connection has been closed. .ie n .IP """$self\->post_client_connection_hook""" 4 .el .IP "\f(CW$self\->post_client_connection_hook\fR" 4 .IX Item "$self->post_client_connection_hook" This is one final hook that occurs at the very end of the run_client_connection method. At this point all other methods and hooks that will run during the run_client_connection have finished and the client connection has already been closed. .Sp item \f(CW\*(C`$self\->other_child_died_hook($pid)\*(C'\fR .Sp Net::Server takes control of signal handling and child process cleanup; this makes it difficult to tell when a child process terminates if that child process was not started by Net::Server itself. If Net::Server notices another child process dying that it did not start, it will fire this hook with the \s-1PID\s0 of the terminated process. .ie n .IP """$self\->pre_server_close_hook()""" 4 .el .IP "\f(CW$self\->pre_server_close_hook()\fR" 4 .IX Item "$self->pre_server_close_hook()" This hook occurs before the server begins shutting down. .ie n .IP """$self\->write_to_log_hook""" 4 .el .IP "\f(CW$self\->write_to_log_hook\fR" 4 .IX Item "$self->write_to_log_hook" This hook handles writing to log files. The default hook is to write to \s-1STDERR,\s0 or to the filename contained in the parameter \f(CW\*(C`log_file\*(C'\fR. The arguments passed are a log level of 0 to 4 (4 being very verbose), and a log line. If log_file is equal to \*(L"Sys::Syslog\*(R", then logging will go to Sys::Syslog and will bypass the write_to_log_hook. .ie n .IP """$self\->fatal_hook""" 4 .el .IP "\f(CW$self\->fatal_hook\fR" 4 .IX Item "$self->fatal_hook" This hook occurs when the server has encountered an unrecoverable error. Arguments passed are the error message, the package, file, and line number. The hook may close the server, but it is suggested that it simply return and use the built in shut down features. .ie n .IP """$self\->post_child_cleanup_hook""" 4 .el .IP "\f(CW$self\->post_child_cleanup_hook\fR" 4 .IX Item "$self->post_child_cleanup_hook" This hook occurs in the parent server process after all children have been shut down and just before the server either restarts or exits. It is intended for additional cleanup of information. At this point pid_files and lockfiles still exist. .ie n .IP """$self\->restart_open_hook""" 4 .el .IP "\f(CW$self\->restart_open_hook\fR" 4 .IX Item "$self->restart_open_hook" This hook occurs if a server has been HUPed (restarted via the \s-1HUP\s0 signal. It occurs just before reopening to the filenos of the sockets that were already opened. .ie n .IP """$self\->restart_close_hook""" 4 .el .IP "\f(CW$self\->restart_close_hook\fR" 4 .IX Item "$self->restart_close_hook" This hook occurs if a server has been HUPed (restarted via the \s-1HUP\s0 signal. It occurs just before restarting the server via exec. .ie n .IP """$self\->child_init_hook()""" 4 .el .IP "\f(CW$self\->child_init_hook()\fR" 4 .IX Item "$self->child_init_hook()" This hook is called during the forking servers. It is also called during run_dequeue. It runs just after the fork and after signals have been cleaned up. If it is a dequeue process, the string \&'dequeue' will be passed as an argument. .Sp If your child processes will be needing random numbers, this hook is a good location to initialize srand (forked processes maintain the same random seed unless changed). .Sp .Vb 4 \& sub child_init_hook { \& # from perldoc \-f srand \& srand(time ^ $$ ^ unpack "%L*", \`ps axww | gzip \-f\`); \& } .Ve .ie n .IP """$self\->pre_fork_hook()""" 4 .el .IP "\f(CW$self\->pre_fork_hook()\fR" 4 .IX Item "$self->pre_fork_hook()" Similar to the child_init_hook, but occurs just before the fork. .ie n .IP """$self\->child_finish_hook()""" 4 .el .IP "\f(CW$self\->child_finish_hook()\fR" 4 .IX Item "$self->child_finish_hook()" Similar to the child_init_hook, but ran when the forked process is about to finish up. .SH "OTHER METHODS" .IX Header "OTHER METHODS" .ie n .IP """$self\->default_values""" 4 .el .IP "\f(CW$self\->default_values\fR" 4 .IX Item "$self->default_values" Allow for returning configuration values that will be used if no other value could be found. .Sp Should return a hashref. .Sp .Vb 5 \& sub default_values { \& return { \& port => 20201, \& }; \& } .Ve .ie n .IP """$self\->handle_syslog_error""" 4 .el .IP "\f(CW$self\->handle_syslog_error\fR" 4 .IX Item "$self->handle_syslog_error" Called when log_file is set to 'Sys::Syslog' and an error occurs while writing to the syslog. It is passed two arguments, the value of $@, and an arrayref containing the arguments that were passed to the log method when the error occured. .ie n .IP """$self\->log""" 4 .el .IP "\f(CW$self\->log\fR" 4 .IX Item "$self->log" Parameters are a log_level and a message. .Sp If log_level is set to 'Sys::Syslog', the parameters may alternately be a log_level, a format string, and format string parameters. (The second parameter is assumed to be a format string if additional arguments are passed along). Passing arbitrary format strings to Sys::Syslog will allow the server to be vulnerable to exploit. The server maintainer should make sure that any string treated as a format string is controlled. .Sp .Vb 1 \& # assuming log_file = \*(AqSys::Syslog\*(Aq \& \& $self\->log(1, "My Message with %s in it"); \& # sends "%s", "My Message with %s in it" to syslog \& \& $self\->log(1, "My Message with %s in it", "Foo"); \& # sends "My Message with %s in it", "Foo" to syslog .Ve .Sp If log_file is set to a file (other than Sys::Syslog), the message will be appended to the log file by calling the write_to_log_hook. .Sp If the log_file is Sys::Syslog and an error occurs during write, the handle_syslog_error method will be called and passed the error exception. The default option of handle_syslog_error is to die \- but could easily be told to do nothing by using the following code in your subclassed server: .Sp .Vb 1 \& sub handle_syslog_error {} .Ve .Sp It the log had been closed, you could attempt to reopen it in the error handler with the following code: .Sp .Vb 4 \& sub handle_syslog_error { \& my $self = shift; \& $self\->open_syslog; \& } .Ve .ie n .IP """$self\->new""" 4 .el .IP "\f(CW$self\->new\fR" 4 .IX Item "$self->new" As of Net::Server 0.91 there is finally a \*(L"new\*(R" method. This method takes a class name and an argument hashref as parameters. The argument hashref becomes the \*(L"server\*(R" property of the object. .Sp .Vb 2 \& package MyPackage; \& use base qw(Net::Server); \& \& my $obj = MyPackage\->new({port => 20201}); \& \& # same as \& \& my $obj = bless {server => {port => 20201}}, \*(AqMyPackage\*(Aq; .Ve .ie n .IP """$self\->open_syslog""" 4 .el .IP "\f(CW$self\->open_syslog\fR" 4 .IX Item "$self->open_syslog" Called during post_configure when the log_file option is set to \&'Sys::Syslog'. By default it use the parsed configuration options listed in this document. If more custom behavior is desired, the method could be overridden and Sys::Syslog::openlog should be called with the custom parameters. .ie n .IP """$self\->shutdown_sockets""" 4 .el .IP "\f(CW$self\->shutdown_sockets\fR" 4 .IX Item "$self->shutdown_sockets" This method will close any remaining open sockets. This is called at the end of the server_close method. .SH "RESTARTING" .IX Header "RESTARTING" Each of the server personalities (except for \s-1INET\s0), support restarting via a \s-1HUP\s0 signal (see \*(L"kill \-l\*(R"). When a \s-1HUP\s0 is received, the server will close children (if any), make sure that sockets are left open, and re-exec using the same commandline parameters that initially started the server. (Note: for this reason it is important that \f(CW@ARGV\fR is not modified until \f(CW\*(C`\->run\*(C'\fR is called). .PP The Net::Server will attempt to find out the commandline used for starting the program. The attempt is made before any configuration files or other arguments are processed. The outcome of this attempt is stored using the method \f(CW\*(C`\->commandline\*(C'\fR. The stored commandline may also be retrieved using the same method name. The stored contents will undoubtedly contain Tainted items that will cause the server to die during a restart when using the \-T flag (Taint mode). As it is impossible to arbitrarily decide what is taint safe and what is not, the individual program must clean up the tainted items before doing a restart. .PP .Vb 2 \& sub configure_hook{ \& my $self = shift; \& \& ### see the contents \& my $ref = $self\->commandline; \& use Data::Dumper; \& print Dumper $ref; \& \& ### arbitrary untainting \- VERY dangerous \& my @untainted = map {/(.+)/;$1} @$ref; \& \& $self\->commandline(\e@untainted) \& } .Ve .SH "SHUTDOWN" .IX Header "SHUTDOWN" Each of the Fork and PreFork personalities support graceful shutdowns via the \s-1QUIT\s0 signal. When a \s-1QUIT\s0 is received, the parent will signal the children and then wait for them to exit. .PP All server personalities support the normal \s-1TERM\s0 and \s-1INT\s0 signal shutdowns. .SH "HOT DEPLOY" .IX Header "HOT DEPLOY" Since version 2.000, the Fork and PreFork personalities have accepted the \s-1TTIN\s0 and \s-1TTOU\s0 signals. When a \s-1TTIN\s0 is received, the max_servers is increased by 1. If a \s-1TTOU\s0 signal is received the max_servers is decreased by 1. This allows for adjusting the number of handling processes without having to restart the server. .PP If the log_level is set to at 3, then the new value is displayed in the logs. .SH "FILES" .IX Header "FILES" The following files are installed as part of this distribution. .PP .Vb 11 \& Net/Server.pm \& Net/Server/Fork.pm \& Net/Server/INET.pm \& Net/Server/MultiType.pm \& Net/Server/PreForkSimple.pm \& Net/Server/PreFork.pm \& Net/Server/Single.pm \& Net/Server/Daemonize.pm \& Net/Server/SIG.pm \& Net/Server/Proto.pm \& Net/Server/Proto/*.pm .Ve .SH "INSTALL" .IX Header "INSTALL" Download and extract tarball before running these commands in its base directory: .PP .Vb 4 \& perl Makefile.PL \& make \& make test \& make install .Ve .SH "AUTHOR" .IX Header "AUTHOR" Paul Seamons <paul at seamons.com> .SH "THANKS" .IX Header "THANKS" Thanks to Rob Brown (bbb at cpan.org) for help with miscellaneous concepts such as tracking down the serialized select via flock ala Apache and the reference to IO::Select making multiport servers possible. And for researching into allowing sockets to remain open upon exec (making \s-1HUP\s0 possible). .PP Thanks to Jonathan J. Miner <miner at doit.wisc.edu> for patching a blatant problem in the reverse lookups. .PP Thanks to Bennett Todd <bet at rahul.net> for pointing out a problem in Solaris 2.5.1 which does not allow multiple children to accept on the same port at the same time. Also for showing some sample code from Viktor Duchovni which now represents the semaphore option of the serialize argument in the PreFork server. .PP Thanks to \fItraveler\fR and \fImerlyn\fR from http://perlmonks.org for pointing me in the right direction for determining the protocol used on a socket connection. .PP Thanks to Jeremy Howard <j+daemonize at howard.fm> for numerous suggestions and for work on Net::Server::Daemonize. .PP Thanks to Vadim <vadim at hardison.net> for patches to implement parent/child communication on PreFork.pm. .PP Thanks to Carl Lewis for suggesting \*(L"\-\*(R" in user names. .PP Thanks to Slaven Rezic for suggesing Reuse => 1 in Proto::UDP. .PP Thanks to Tim Watt for adding udp_broadcast to Proto::UDP. .PP Thanks to Christopher A Bongaarts for pointing out problems with the Proto::SSL implementation that currently locks around the socket accept and the \s-1SSL\s0 negotiation. See Net::Server::Proto::SSL. .PP Thanks to Alessandro Zummo for pointing out various bugs including some in configuration, commandline args, and cidr_allow. .PP Thanks to various other people for bug fixes over the years. These and future thank-you's are available in the Changes file as well as \&\s-1CVS\s0 comments. .PP Thanks to Ben Cohen and tye (on Permonks) for finding and diagnosing more correct behavior for dealing with re-opening \s-1STDIN\s0 and \s-1STDOUT\s0 on the client handles. .PP Thanks to Mark Martinec for trouble shooting other problems with \s-1STDIN\s0 and \s-1STDOUT \s0(he proposed having a flag that is now the no_client_stdout flag). .PP Thanks to David (\s-1DSCHWEI\s0) on cpan for asking for the nofatal option with syslog. .PP Thanks to Andreas Kippnick and Peter Beckman for suggesting leaving open child connections open during a \s-1HUP \s0(this is now available via the leave_children_open_on_hup flag). .PP Thanks to \s-1LUPE\s0 on cpan for helping patch \s-1HUP\s0 with taint on. .PP Thanks to Michael Virnstein for fixing a bug in the check_for_dead section of PreFork server. .PP Thanks to Rob Mueller for patching PreForkSimple to only open lock_file once during parent call. This patch should be portable on systems supporting flock. Rob also suggested not closing \s-1STDIN/STDOUT\s0 but instead reopening them to /dev/null to prevent spurious warnings. Also suggested short circuit in post_accept if in \s-1UDP. \s0 Also for cleaning up some of the child managment code of PreFork. .PP Thanks to Mark Martinec for suggesting additional log messages for failure during accept. .PP Thanks to Bill Nesbitt and Carlos Velasco for pointing out double decrement bug in PreFork.pm (rt #21271) .PP Thanks to John W. Krahn for pointing out glaring precended with non-parened open and ||. .PP Thanks to Ricardo Signes for pointing out setuid bug for perl 5.6.1 (rt #21262). .PP Thanks to Carlos Velasco for updating the Syslog options (rt #21265). And for additional fixes later. .PP Thanks to Steven Lembark for pointing out that no_client_stdout wasn't working with the Multiplex server. .PP Thanks to Peter Beckman for suggesting allowing Sys::SysLog keyworks be passed through the \->log method and for suggesting we allow more types of characters through in syslog_ident. Also to Peter Beckman for pointing out that a poorly setup localhost will cause tests to hang. .PP Thanks to Curtis Wilbar for pointing out that the Fork server called post_accept_hook twice. Changed to only let the child process call this, but added the pre_fork_hook method. .PP And just a general Thanks You to everybody who is using Net::Server or who has contributed fixes over the years. .PP Thanks to Paul Miller for some \->autoflush, FileHandle fixes. .PP Thanks to Patrik Wallstrom for suggesting handling syslog errors better. .PP Thanks again to Rob Mueller for more logic cleanup for child accounting in PreFork server. .PP Thanks to David Schweikert for suggesting handling setlogsock a little better on newer versions of Sys::Syslog (>= 0.15). .PP Thanks to Mihail Nasedkin for suggesting adding a hook that is now called post_client_connection_hook. .PP Thanks to Graham Barr for adding the ability to set the check_for_spawn and min_child_ttl settings of the PreFork server. .PP Thanks to Daniel Kahn Gillmor for adding the other_child_died_hook. .PP Thanks to Dominic Humphries for helping not kill pid files on \s-1HUP.\s0 .PP Thanks to Kristoffer Mo\*/llerho\*/j for fixing \s-1UDP\s0 on Multiplex. .PP Thanks to mishikal for patches for helping identify un-cleaned up children. .PP Thanks to rpkelly and tim@retout for pointing out error in header regex of \s-1HTTP.\s0 .PP Thanks to dmcbride for some basic \s-1HTTP\s0 parsing fixes, as well as for some broken tied handle fixes. .PP Thanks to Gareth for pointing out glaring bug issues with broken pipe and semaphore serialization. .PP Thanks to \s-1CATONE\s0 for sending the idea for arbitrary signal passing to children. (See the sig_passthrough option) .PP Thanks to intrigeri@boum for pointing out and giving code ideas for NS_port not functioning after a \s-1HUP.\s0 .PP Thanks to Sergey Zasenko for adding sysread/syswrite support to \s-1SSLEAY\s0 as well as the base test. .PP Thanks to mbarbon@users. for adding tally dequeue to prefork server. .PP Thanks to stefanos@cpan for fixes to PreFork under Win32 .PP Thanks to Mark Martinec for much of the initial work towards getting IPv6 going. .PP Thanks to the munin developers and Nicolai Langfeldt for hosting the development verion of Net::Server for so long and for fixes to the allow_deny checking for IPv6 addresses. .PP Thanks to Tatsuhiko Miyagawa for feedback, and for suggesting adding graceful shutdowns and hot deploy (max_servers adjustment). .PP Thanks to TONVOON@cpan for submitting a patch adding Log4perl functionality. .PP Thanks to Miko O'Sullivan for fixes to \s-1HTTP\s0 to correct tainting issues and passing initial log fixes, and for patches to fix \s-1CLOSE\s0 on tied stdout and various other \s-1HTTP\s0 issues. .SH "SEE ALSO" .IX Header "SEE ALSO" Please see also Net::Server::Fork, Net::Server::INET, Net::Server::PreForkSimple, Net::Server::PreFork, Net::Server::MultiType, Net::Server::Single Net::Server::HTTP .SH "TODO" .IX Header "TODO" Improve test suite to fully cover code (using Devel::Cover). Anybody that wanted to send me patches to the t/*.t tests that improved coverage would earn a big thank you. .SH "CODE REPOSITORY" .IX Header "CODE REPOSITORY" https://github.com/rhandom/perl\-net\-server .SH "AUTHOR" .IX Header "AUTHOR" .Vb 2 \& Paul Seamons <paul at seamons.com> \& http://seamons.com/ \& \& Rob Brown <bbb at cpan.org> .Ve .SH "LICENSE" .IX Header "LICENSE" This package may be distributed under the terms of either the .PP .Vb 3 \& GNU General Public License \& or the \& Perl Artistic License .Ve .PP All rights reserved. .SH "POD ERRORS" .IX Header "POD ERRORS" Hey! \fBThe above document had some coding errors, which are explained below:\fR .IP "Around line 1751:" 4 .IX Item "Around line 1751:" Non-ASCII character seen before =encoding in 'Mo\*/llerho\*/j'. Assuming \s-1UTF\-8\s0