Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
All I want to do is record (for now send to stdout) that data, AND here's the problem, be able to kill the listner at any time.
But when I kill the listner, the sending host stays in CLOSE_WAIT
anywhay here's my dumb little program ....
Am I trying to do something that can't be done ?------------------------------------------------- #!/usr/bin/perl use IO::Socket; use IO::Select; sub sig_do { my $signame = shift; $got_usr1++; } $shucks = 0; $SIG{USR1} = \&sig_do; $local_port = 2282; $local = IO::Socket::INET->new(Proto=>"tcp", LocalPort=>$local_port, Listen=>"1" ) or die "Can't open socket\n"; # wait for connection and create a new handle $remote = $local->accept; while (<$remote>) { if($got_usr1) { last }; $data = $_; $peer_addr = $remote->peerhost; print "PEER:$peer_addr DATA:$data"; #play with data .... } printf "USR1 signal, now close the connection\n"; close $remote; close $local; -----------------------------------------------------
Thanks for any help ...
-pete
Edit kudra, 2002-08-19 Changed title
|
|---|