------------------------------------------------- #!/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; -----------------------------------------------------