in reply to Tkx and tcp server

Hi, I don't do Tkx, but it is similar to Tk, which I am familiar with.

I googled for "tkx fileevent" and came up with this code usage

my $fh = Tkx::open("| @cmds <$null 2>\@1"); Tkx::fconfigure($fh, -blocking => 0); Tkx::fileevent($fh, readable => [\&run_watch, $fh]);
It LOOKS like you need to pass in an arrayref, rather than a sub.

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: Tkx and tcp server
by momo33 (Beadle) on Mar 18, 2011 at 15:40 UTC
    Moving forward, but not all the way.
    The $fh (filehandle) is not the same as $server. My error:
    can not find channel named "IO::Socket::INET=GLOB(0xa119ed0)" at ./spshow_simple.pl line 24.
    Offending sourcecode line: Tkx::fconfigure($server, -blocking => 0);

    Thank you
      I'm just guessing here, but you apparently still don't have the fileevent syntax correct. You still have
      Tkx::fileevent( $client, readable =>[\&handle_connection, \$client] ); # whereas the correct syntax I previously posted is Tkx::fileevent($fh, readable => [\&run_watch, $fh]);
      Notice, you have \$client as a reference instead of a plain filehandle

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh
      FWIW, there is no need to resort to the Tcl blocking method, you can use $server->blocking(0);
Re^2: Tkx and tcp server
by Anonymous Monk on Mar 19, 2011 at 03:46 UTC
    I googled for "tkx fileevent" and came up with this code usage
    ++ good show!
      That is right, but the example uses a file instead of a socket:
      my $fh = Tkx::open("| @cmds <$null 2>\@1");