in reply to Perl/Tk telnet client - reading server input in an Event Driven environment

You might want to try the fileevent method of tk:
$widget->fileevent(fileHandle,readable?,callback?)

This command is used to create file event handlers. A file event handler is a binding between a filehandle and a callback, such that the callback is evaluated whenever the filehandle becomes readable or writable
  • Comment on Re: Perl/Tk telnet client - reading server input in an Event Driven environment
  • Download Code

Replies are listed 'Best First'.
Re: Re: Perl/Tk telnet client - reading server input in an Event Driven environment
by tmiklas (Hermit) on Mar 23, 2002 at 22:39 UTC
    Hi!

    I've never used the fileevent() so i may be wrong, but as for me 'readable' or 'writable' means, that the file is accessible in such mode - it doesn't mean that there is some data to read.
    I found this problem using IO::Select's can_read() function. It returns all the file handles that are 'readable', but you still won't know which of them has an input waiting... Maybe it would work better for me if i used flock() on those files between data reads? Never mind - i've got a work-around ;-)

    Greetz, Tom.
      From the Tk::fileevent doc: A filehandle is considered to be readable if there is unread data available on the underlying device.
        Ok - you are right. Sorry for disturbing your discussion.

        Greetz, Tom.