Is there some kind of event for a connection that goes away gracefully
without saying "goodbye" in some fashion (TCP)?
When I slam the door on my SocketFactory by aborting a connection made to it
via wget, it doesn't throw a FailureEvent, so I'm not sure how to clean
things up gracefully on my end.
Or did I miss something?
I have:
sub _start {
my( $kernel, $self ) = @_[ KERNEL, OBJECT ];
$kernel->sig('INT', 'signals');
$kernel->alias_set('httpserver');
$self->{wheel} = POE::Wheel::SocketFactory->new(
BindPort => 8080,
Reuse => 'yes',
SuccessEvent => 'socket_connect',
FailureEvent => 'socket_broken'
);
warn "Listening to port 8080 on all interfaces.\n";
}
sub socket_broken {
my( $self, $op, $errnum, $errstr, $wheel_id ) = @_[ OBJECT, ARG0, ARG1,
ARG2, ARG3 ];
warn "Wheel $wheel_id generated $op error $errnum: $errstr\n";
warn "Someone else has the socket or a previous process didn't exit
cleanly\n"
if $errnum == 98;
# If we delete the socket we're listening on then we can't listen anymore,
# so
# don't delete the socket on failure!
}
The warn error never shows when I kill the program talking to the socket, but
the code called in my SuccessEvent gets killed with extreme prejudice, so
something in POE must be figuring out the connection 'went away'. There must
be some way for me to get this event, so I can act upon it.
sub socket_connect {
my( $self, $socket, $remote_addr, $port ) = @_[ OBJECT, ARG0, ARG1, ARG2 ];
my $peer_host = inet_ntoa($_[ARG1]);
# service it with HTTPSession
$self->{requests}++;
HTTPServerSession->new(
$socket, $peer_host, $port
);
}
I'd like to be able to get word to HTTPServerSession's object that it's work
is done so it can do a $self->{run_wheel}->kill() and clean up some other
miscellaneous things before going away.
Thanks. :)