package Net::Server::INET;
use strict;
use vars qw(@ISA $VERSION);
use Net::Server;
$VERSION = $Net::Server::VERSION;
@ISA = qw(Net::Server);
sub post_configure {
my $self = shift;
$self->{server}->{_is_inet} = 1;
$self->SUPER::post_configure();
delete $self->{server}->{_is_inet};
}
sub pre_bind {}
sub bind {}
sub accept {
my $self = shift;
my $prop = $self->{server};
delete $prop->{udp_true};
1;
}
sub done { 1 }
sub post_accept {
my $self = shift;
$self->{server}->{client} = Net::Server::INET::Handle->new();
}
sub hup_server {}
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 '';
}
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 {}
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