in reply to Re^5: How to Multiplex a Client using IO::Select
in thread How to Multiplex a Client using IO::Select

How would you construct the above snippet?

my ($r, $w) = winsocketpair(); $w->autoflush(1); async { print $w $_ while defined( $_ = <STDIN> ); }->detach; while( 1 ) { if ( my ($readers, $writers, $exceptors) = IO::Select::select($selector, $selector, $selector) ) { for( @$readers ) { ## See what they have to say } for( @$writers ) { ## Tell'em what they need to know } for( @$exceptors ) { ## Deal with their tantrums } } }

Have you tried Win32::Socketpair yet?

Turns out it crashes :(

Update: Removing the calls to ioctl removes the crash and makes the module work. I don't know at what cost, though.

Replies are listed 'Best First'.
Re^7: How to Multiplex a Client using IO::Select
by BrowserUk (Patriarch) on Oct 13, 2008 at 14:49 UTC
    Update: Removing the calls to ioctl removes the crash and makes the module work. I don't know at what cost, though.

    Do you mean the two ioctl calls inside the module? Or were there some in your code above that you've removed?

    If the former, then I think that things may be improved, if not fixed, by changing

    ioctl($client, 0x8004667e, 1);

    to

    my $true = 1; ioctl($client, 0x8004667e, \$true );

    I've certainly had code where a similar change prevented traps in the past. I'm not sure if the same is necessary for the ioctl($client, 0x8004667e, 0); case. I'm still a bit perplexed by the logic in the module, and the need for that latter call?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Yes, the two ioctl calls inside the module. And I tried what you suggest and got bad file descriptor errors. Didn't look from what. I didn't care anymore at that point, since the module is obviously not going to be used here.