in reply to Re: Fork and pipe
in thread Fork and pipe

The following code still seems unresponsive (can't click on button, and label is not refreshed). This must be a windows thing.

use Tk; use IO::Socket; use strict; my $sock; my $port = 7076; my $time = 60; my $mw = MainWindow->new; my $button = $mw->Button(-text=>"click", -command=>sub{exit;})->place(-x=>0,-y=>0); my $l = $mw->Label(-text=>"$time")->place(-x=>0,-y=>50); $mw->update; $sock = new IO::Socket::INET ( LocalHost => 'localhost', LocalPort => $port, Proto => 'tcp', Listen => 1, Reuse => 1, #Timeout => 0.1, ); die "Could not create socket: $!\n" unless $sock; $mw->fileevent($sock,'readable',[\&readit]); $mw->repeat(100,sub{$l->configure(-text=>$time--);$mw->update;}); MainLoop; sub readit{ my $new_sock = $sock->accept(); my $in = <$new_sock>; print "received $in\n"; }