in reply to Re: Alternative for Select for pipes in Windows?
in thread Alternative for Select for pipes in Windows?

Unfortunately, the installation of Win32-Socketpair fails in both: ActivePerl 5.10 and Strawberry 5.12. The make Test fails... I will try to force the installation in Starwberry anyways....In ActivePerl it proved to make perl hang when trying to run the script.

  • Comment on Re^2: Alternative for Select for pipes in Windows?

Replies are listed 'Best First'.
Re^3: Alternative for Select for pipes in Windows?
by BrowserUk (Patriarch) on Nov 06, 2010 at 05:07 UTC

    Replace the winsocket pair sub with this:

    sub winsocketpair { my $proto = getprotobyname('tcp'); my $first = 1; for (1..5) { if ($first) { undef $first; } else { carp "winsocketpair failed: $!, retrying" } socket(my $listener, AF_INET, SOCK_STREAM, $proto) or return (); socket(my $server, AF_INET, SOCK_STREAM, $proto) or return (); socket(my $client, AF_INET, SOCK_STREAM, $proto) or return (); my $true = 1; ioctl($client, 0x8004667e, \$true ); my $addr = sockaddr_in(0, INADDR_LOOPBACK); bind($listener, $addr) or return (); listen($listener, 1) or return (); $addr = getsockname($listener); connect($client, $addr) or $! == 10035 or $! == EINPROGRESS or next; my $peer = accept($server, $listener) or next; my $false = 0; ioctl($client, 0x8004667e, \$false ); if ($peer eq getsockname($client)) { return ($server, $client); } } return (); }

    And ignore make test--the tests seem to be broken. They sometime pass and sometimes fail?


    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.

        Maybe salva will explain why he didn't use that in the first place.


        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.

      I can not tell if the original suggestions work, because after careful consideration, I have decided to approach my needs from a different and way more easier perspective.

      What I'd like to say thou, is that the modification to the subroutine winsocketpair suggested by BrowserUk (see above), stopped making my perl interpreter to hang up.So, whoever comes behind me looking for a solution that requieres Win32::Socketpair, be aware of this needed modification.

      Additionally, in my particular case, "use threads qw( async );" complains that "async" is an unknow import, even thou I verified it is there in threads.pm, go figure.

      Many thanks to ikegami, BrowserUk and everyone else for the help provided.

      Best regards

      matematiko

        in my particular case, "use threads qw( async );" complains that "async" is an unknow import,

        async is exported by default, so it is not necessary to import it explicitly.

        Indeed, as long as I can remember, attempting to import it has resulted in an error message:

        threads: Unknown import option: async at ...

        That's the problem with people posting "theoretical answers" for things they've never actually done!


        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.