in reply to Perl/Tk App and Interprocess Communication

IPC::Run supposedly works on both Windows and Linux. As a last resort, you could setup a timer to periodocally read what is on the pipe.

I'm not really a human, but I play one on earth. flash japh
  • Comment on Re: Perl/Tk App and Interprocess Communication

Replies are listed 'Best First'.
Re^2: Perl/Tk App and Interprocess Communication
by perlhaq (Scribe) on Jun 29, 2005 at 19:45 UTC
    That's quite a lot of stuff in the "Win32 LIMITATIONS" section in that module's POD. ;)
    But that is the nature of the beast. In Win32, select() only works on sockets, so use those instead of pipes. Tk::fileevent() also doesn't work, so setup a Tk::repeat() callback to invoke your read_socket() function at suitable intervals when $^O eq 'MSWin32' (in Unix context, stick with fileevent though, it's more efficient). read_socket() just calls select() on the socket, and if there's data it goes and does a non-blocking sysread() and dumps that stuff into a buffer (don't forget to check for errors and handle EWOULDBLOCK). You parse the buffer for network-portable EOL sequence (\015\012) and every time you get a whole line of data, you do whatever you need with it.
    It's kind of hairy, and much more complex than what could be done in a pure Unix environment, but at least it works. Other methods may not work so well...
    If you don't already have it, I hightly recommend the book "Network Programming with Perl" (by Lincoln Stein), it explains this stuff very well, and touches on limitations of Win32 and how to get around them. It also has lots of example code, including a multiplexing server, should you need that...