/usr/share/perl5/Net/Server/INET.pm is in libnet-server-perl 0.99-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | # -*- perl -*-
#
# Net::Server::INET - Net::Server personality
#
# $Id: INET.pm,v 1.8 2010/05/05 04:38:57 rhandom Exp $
#
# Copyright (C) 2001-2007
#
# Paul Seamons
# paul@seamons.com
# http://seamons.com/
#
# This package may be distributed under the terms of either the
# GNU General Public License
# or the
# Perl Artistic License
#
# All rights reserved.
#
################################################################
package Net::Server::INET;
use strict;
use vars qw(@ISA $VERSION);
use Net::Server;
$VERSION = $Net::Server::VERSION; # done until separated
@ISA = qw(Net::Server);
sub post_configure {
my $self = shift;
$self->{server}->{_is_inet} = 1;
$self->SUPER::post_configure();
delete $self->{server}->{_is_inet};
}
### no need to prepare bind
sub pre_bind {}
### inet has no port to bind
sub bind {}
### connection is already accepted
sub accept {
my $self = shift;
my $prop = $self->{server};
### Net::Server::INET will not do any determination of TCP,UDP,Unix
### it is up to the programmer to keep these as separate processes
delete $prop->{udp_true};
### receive a udp packet
# if( $prop->{udp_true} ){
# $prop->{client} = *STDIN;
# $prop->{udp_peer} = STDIN->recv($prop->{udp_data},
# $prop->{udp_packet_size},
# $prop->{udp_packet_offset});
# }
1;
}
### accept only one connection per process
sub done { 1 }
### set up handles
sub post_accept {
my $self = shift;
### STDIN and STDOUT are already bound
### create a handle for those who want to use
### an IO::Socket'ish handle - more portable
### to just use STDIN and STDOUT though
$self->{server}->{client} = Net::Server::INET::Handle->new();
}
### can't hup single process
sub hup_server {}
################################################################
### the rest are methods to tie STDIN and STDOUT to a GLOB
### this most likely isn't necessary, but the methods are there
### support for this is experimental and may go away
################################################################
package Net::Server::INET::Handle;
use vars qw(@ISA);
use strict;
use IO::Handle ();
@ISA = qw(IO::Handle);
sub new {
my $class = shift;
local *HAND;
STDIN->autoflush(1);
STDOUT->autoflush(1);
tie( *HAND, $class, *STDIN, *STDOUT)
or die "can't tie *HAND: $!";
bless \*HAND, $class;
return \*HAND;
}
sub NS_proto {
return '';
}
### tied handle methods
sub TIEHANDLE {
my ($class, $in, $out) = @_;
bless [ \$in, \$out ], $class;
}
sub PRINT {
my $handle = shift()->[1];
local *FH = $$handle;
CORE::print FH @_;
}
sub PRINTF {
my $handle = shift()->[1];
local *FH = $$handle;
CORE::printf FH @_;
}
sub WRITE {
my $handle = shift()->[1];
local *FH = $$handle;
local ($\) = "";
$_[1] = length($_[0]) unless defined $_[1];
CORE::print FH substr($_[0], $_[2] || 0, $_[1]);
}
sub READ {
my $handle = shift()->[0];
local *FH = $$handle;
CORE::read(FH, $_[0], $_[1], $_[2] || 0);
}
sub READLINE {
my $handle = shift()->[0];
local *FH = $$handle;
return scalar <FH>;
}
sub GETC {
my $handle = shift()->[0];
local *FH = $$handle;
return CORE::getc(FH);
}
sub EOF {
my $handle = shift()->[0];
local *FH = $$handle;
return CORE::eof(FH);
}
sub OPEN {}
sub CLOSE {
my $self = shift;
$self = undef;
}
sub BINMODE {}
sub TELL {}
sub SEEK {}
sub DESTROY {}
sub FILENO {}
sub FETCH {}
sub read_until { # only sips the data - but it allows for compatibility with SSLEAY
my ($client, $bytes, $end_qr) = @_;
die "One of bytes or end_qr should be defined for TCP read_until\n" 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::INET - Net::Server personality
=head1 SYNOPSIS
use Net::Server::INET;
@ISA = qw(Net::Server::INET);
sub process_request {
#...code...
}
Net::Server::INET->run();
=head1 DESCRIPTION
Please read the pod on Net::Server first. This module
is a personality, or extension, or sub class, of the
Net::Server module.
This personality is intended for use with inetd. It offers
no methods beyond the Net::Server base class. This module
operates by overriding the pre_bind, bind, accept, and
post_accept methods to let all socket processing to be done
by inetd.
=head1 CONFIGURATION FILE
See L<Net::Server>.
=head1 PROCESS FLOW
See L<Net::Server>
=head1 HOOKS
There are no additional hooks in Net::Server::INET.
=head1 TO DO
See L<Net::Server>
=head1 AUTHOR
Paul T. Seamons paul@seamons.com
=head1 SEE ALSO
Please see also
L<Net::Server::Fork>,
L<Net::Server::INET>,
L<Net::Server::PreFork>,
L<Net::Server::MultiType>,
L<Net::Server::Single>
=cut
|