$VERSION
=
'1.01'
;
sub
init($)
{
my
(
$self
,
$args
) =
@_
;
$args
->{Proto} ||=
'tcp'
;
my
$socket
=
$args
->{fh}
= (
delete
$args
->{
socket
}) ||
$self
->extractSocket(
$args
);
$args
->{name} ||=
"tcp "
.
$socket
->peerhost.
':'
.
$socket
->peerport;
$self
->IOMux::Handler::Read::init(
$args
);
$self
->IOMux::Handler::Write::init(
$args
);
$self
;
}
sub
socket
() {
shift
->fh}
sub
shutdown
($)
{
my
(
$self
,
$which
) =
@_
;
my
$socket
=
$self
->
socket
;
my
$mux
=
$self
->mux;
if
(
$which
!=1)
{
$socket
->
shutdown
(0);
$self
->{IMNT_shutread} = 1;
$self
->fdset(0, 1, 0, 0);
}
if
(
$which
!=0)
{
$self
->{IMNT_shutwrite} = 1;
unless
(
$self
->muxOutputWaiting)
{
$socket
->
shutdown
(1);
$self
->fdset(0, 0, 1, 0);
}
}
$self
->
close
if
$self
->{IMNT_shutread}
&&
$self
->{IMNT_shutwrite} && !
$self
->muxOutputWaiting;
}
sub
close
()
{
my
$self
=
shift
;
warning __x
"closing {name} with read buffer"
,
name
=>
$self
->name
if
length
$self
->{ICMT_inbuf};
warning __x
"closing {name} with write buffer"
,
name
=>
$self
->name
if
$self
->{ICMT_outbuf};
$self
->
socket
->
close
;
$self
->SUPER::
close
;
}
sub
muxInit($)
{
my
(
$self
,
$mux
) =
@_
;
$self
->SUPER::muxInit(
$mux
);
$self
->fdset(1, 1, 0, 1);
}
sub
muxOutbufferEmpty()
{
my
$self
=
shift
;
$self
->SUPER::muxOutbufferEmpty;
if
(
$self
->{IMNT_shutwrite} && !
$self
->muxOutputWaiting)
{
$self
->
socket
->
shutdown
(1);
$self
->fdset(0, 0, 1, 0);
$self
->
close
if
$self
->{IMNT_shutread};
}
}
1;