in reply to Re: Sync messages for chatting peers
in thread Sync messages for chatting peers

To Almut:

Thanks for pointing out the problem. I am trying to solve it as you explained. But it seems that Term::ReadKey module non-blocking readline feature is NOT well supported in Windows either.

To rowdog:

Yes, I read the doc, unforturnely, my script works under windows, but fork() is NOT well supported in Wins. I tested it under both Ubuntu and Windows XP with the same code.
#!/usr/bin/perl my $i = 0; my $in; while( 1 ){ ++$i; my $pid = fork(); if ( $pid ){ $in = <>; chomp( $in ); print "Child: $in\n"; } else{ print "Parent: $i \n"; sleep 5; } }
In Linux, it works fine, while screen update still hangs at reading input, requires <enter> key to trigger the update.

Thanks,

Yun

Replies are listed 'Best First'.
Re^3: Sync messages for chatting peers
by rowdog (Curate) on Mar 25, 2010 at 20:05 UTC

    I don't do Windows but I believe the usual advice would be to use threads. BrowserUk posted a nice example of a (non-blocking) threaded client at Re: Sockets and threads, oh my!

    That client code is 4 years old and I'm not sure if you still need to do the ioctl song and dance to get Windows to give you a non-blocking socket (if you even want one), but the principles should still be relevant.

      Thanks rowdog,

      BrowserUK's code works fine, again thanks for the patience and guide. I will renew the original code, just in case that someone might would like to.

      Thanks

      Yun