There's more than one way to do things | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
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... In reply to Re^2: Perl/Tk App and Interprocess Communication
by perlhaq
|
|