fileevent doesn't work with ActivePerl 5.6.1 or 5.8.0. I'm not sure about other versions. I'm really upset about the whole thing, too, since POE requires fileevent to work with Tk.

Anyway, here's a test case (pure Tk) that you can use to verify whether fileevent works with your OS/Perl/Tk environment. It should be portable across UNIX and Win32.

-- Rocco Caputo - troc@pobox.com - poe.perl.org

#!/usr/bin/perl -w use strict; use Tk; use Symbol qw(gensym); use IO::Socket; $ENV{HOME} = "/" unless $ENV{HOME}; print( "Listening on localhost port 31415. Telnet to it and try\n", "entering something. In an ideal world, it should echo back.\n +" ); my $acceptor = IO::Socket::INET->new ( LocalAddr => '127.0.0.1', LocalPort => 31415, Listen => 5, Reuse => 'yes', ); my $client = $acceptor->accept(); die "Could not accept a client: $!" unless defined $client; print "Client connection accepted.\n"; # Turn off buffering. select((select($client), $| = 1)[0]); # Send a welcome message. print $client "Hello!\x0d\x0a"; print "Setting callback for $client.\n"; my $main_window = Tk::MainWindow->new(); $main_window->fileevent( $client, 'readable', [ \&read_client ] ); print "Callback set.\n"; Tk::MainLoop(); exit 0; sub read_client { print "Client callback has been invoked.\n"; my $line = <$client>; exit unless defined $line; print $client $line; }

In reply to Re: Re: Tk and blocking loops by rcaputo
in thread Tk and blocking loops by sbrandt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.