Net-Server

 view release on metacpan or  search on metacpan

lib/Net/Server/Proto/UNIX.pm  view on Meta::CPAN

    } else {
        $client = $sock->SUPER::accept($class);
    }
    if (defined $client) {
        $client->NS_port($sock->NS_port);
    }
    return wantarray ? ($client, $peername) : $client;
}

# a string containing any information necessary for restarting the server
# via a -HUP signal
# a newline is not allowed
# the hup_string must be a unique identifier based on configuration info
sub hup_string {
    my $sock = shift;
    return join "|", $sock->NS_host, $sock->NS_port, $sock->NS_proto, $sock->NS_ipv;
}

sub show {
    my $sock = shift;
    return "Ref = \"".ref($sock). "\" (".$sock->hup_string.")\n";
}

###----------------------------------------------------------------###

sub read_until { # only sips the data - but it allows for compatibility with SSLEAY
    my ($client, $bytes, $end_qr) = @_;
    croak "read_until: One of bytes or end_qr should be defined" if !defined($bytes) && !defined($end_qr);
    my $content = '';
    my $ok = 0;
    while (1) {
        $client->read($content, 1, length($content));
        if (defined($bytes) && length($content) >= $bytes) {
            $ok = 2;
            last;
        } elsif (defined($end_qr) && $content =~ $end_qr) {
            $ok = 1;
            last;
        }
    }
    return wantarray ? ($ok, $content) : $content;
}

1;

__END__

=head1 NAME

Net::Server::Proto::UNIX - Net::Server UNIX protocol.

=head1 SYNOPSIS

See L<Net::Server::Proto>.

=head1 DESCRIPTION

Protocol module for Net::Server.  This module implements the UNIX
SOCK_STREAM socket type.  See L<Net::Server::Proto>.

Any sockets created during startup will be chown'ed to the user and
group specified in the startup arguments.

=head1 PARAMETERS

The following parameters may be specified in addition to normal
command line parameters for a Net::Server.  See L<Net::Server> for
more information on reading arguments.

=over 4

=item unix_type

Can be either SOCK_STREAM or SOCK_DGRAM (default is SOCK_STREAM).
This can also be passed on the port line (see L<Net::Server::Proto>).

However, this method is deprecated.  If you want SOCK_STREAM - just
use proto UNIX without any other arguments.  If you'd like SOCK_DGRAM,
use the new proto UNIXDGRAM.

=back

=head1 METHODS

=over 4

=item NS_unix_path/NS_unix_type

In addition to the standard NS_ methods of Net::Server::Proto classes,
the UNIX types also have legacy calls to NS_unix_path and
NS_unix_type.

Since version 2.000, NS_unix_path is simply an alias to NS_port.
NS_unix_type is now redundant with NS_proto.

These methods were missing between version 2.000 and 2.003 but have
been returned as legacy bridges.

=back

=head1 QUICK PARAMETER LIST

  Key               Value                    Default

  # deprecated UNIX socket parameters
  unix_type         (SOCK_STREAM|SOCK_DGRAM) SOCK_STREAM
  port              "filename"               undef

  # more recent usage
  port              "filename / UNIX"
  port              "filename / UNIXDGRAM"

=head1 LICENCE

Distributed under the same terms as Net::Server

=cut



( run in 1.063 second using v1.01-cache-2.11-cpan-92ad3014f07 )