Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to get a simple 'listner' to work. Here is what I have; A host that is constantly sending text to another host on a particular port.

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 ....

------------------------------------------------- #!/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; -----------------------------------------------------
Am I trying to do something that can't be done ?

Thanks for any help ...

-pete

Edit kudra, 2002-08-19 Changed title

  • Comment on IO:socket client stays in CLOSE_WAIT after close (was: IO::Socket question from total newbie)
  • Download Code