I realize that this is not necessarily the answer to the question I was orignially asking, but it certainly is a solution to my problem (see the parent node). The problem was that I could not have a responsive Tk GUI running in parallel with a blocking socket read (Tk::fileevent under Win32 is broken - at least on perl 5.6.1 - I think it should be fixed by 5.7 or 5.8). Well, FYI, here's a hack that works.
use IO::Socket; use IO::Select; use Tk; use strict; my $mw = MainWindow->new; my $text = $mw->Text->pack(); my $button = $mw->Button(-text=>"quit",-command=>sub{exit;})->pack; my $sock = IO::Socket::INET->new( Listen => 5, Reuse => 1, LocalPort => 7076, Proto => 'tcp', ) or die "Couldn't open socket: $!"; my $sel = IO::Select->new; $sel->add($sock); $mw->repeat(50 => \&read_sock); MainLoop; sub read_sock { my(@ready) = $sel->can_read(0); return if $#ready == -1; my $line; my $new_sock = $sock->accept(); $line = <$new_sock>; $text->insert('end',"$line\n"); }
In reply to Solution to my problem
by gri6507
in thread Catching signals
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |