Net-Daemon

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

                               'description' => '--base                  '
                                      . 'dec (default), hex or oct'
                                };
        $options;
    }

    # Treat command line option in the constructor
    sub new ($$;$) {
        my($class, $attr, $args) = @_;
        my($self) = $class->SUPER::new($attr, $args);
        if ($self->{'options'}  &&  $self->{'options'}->{'base'}) {
            $self->{'base'} = $self->{'options'}->{'base'}
        }
        if (!$self->{'base'}) {
            $self->{'base'} = 'dec';
        }
        $self;
    }

    # Initialize per-connection state after Clone()
    sub post_clone ($) {
        my($self) = @_;
        $self->{'base'} = $self->{'parent'}->{'base'};
    }

    sub Run ($) {
        my($self) = @_;
        my($line, $sock);
        $sock = $self->{'socket'};
        while (1) {
            if (!defined($line = $sock->getline())) {
                if ($sock->error()) {
                    $self->Error("Client connection error %s",
                                 $sock->error());
                }
                $sock->close();
                return;
            }
            $line =~ s/\s+$//; # Remove CRLF
            my($result) = eval $line;
            my($rc);
            if ($self->{'base'} eq 'hex') {
                $rc = printf $sock ("%x\n", $result);
            } elsif ($self->{'base'} eq 'oct') {
                $rc = printf $sock ("%o\n", $result);
            } else {
                $rc = printf $sock ("%d\n", $result);
            }
            if (!$rc) {
                $self->Error("Client connection error %s",
                             $sock->error());
                $sock->close();
                return;
            }
        }
    }

    package main;

    my $server = Calculator->new({'pidfile' => 'none',
                                  'localport' => 2000}, \@ARGV);
    $server->Bind();

# KNOWN PROBLEMS

Most, or even any, known problems are related to the Sys::Syslog module
which is by default used for logging events under Unix. I'll quote some
examples:

- Usage: Sys::Syslog::\_PATH\_LOG at ...

    This problem is treated in perl bug 20000712.003. A workaround is
    changing line 277 of Syslog.pm to

        my $syslog = &_PATH_LOG() || croak "_PATH_LOG not found in syslog.ph";

# AUTHOR AND COPYRIGHT

    Net::Daemon is Copyright (C) 1998, Jochen Wiedmann
                                       Am Eisteich 9
                                       72555 Metzingen
                                       Germany

                                       Phone: +49 7123 14887
                                       Email: joe@ispsoft.de

    All rights reserved.

    You may distribute this package under the terms of either the GNU
    General Public License or the Artistic License, as specified in the
    Perl README file.

# SEE ALSO

[RPC::pServer(3)](http://man.he.net/man3/RPC::pServer), [Netserver::Generic(3)](http://man.he.net/man3/Netserver::Generic), [Net::Daemon::Log(3)](http://man.he.net/man3/Net::Daemon::Log),
[Net::Daemon::Test(3)](http://man.he.net/man3/Net::Daemon::Test)



( run in 0.901 second using v1.01-cache-2.11-cpan-98e64b0badf )