in reply to Re^13: Is there a problem with IPC::Open on Windows 7?
in thread Is there a problem with IPC::Open on Windows 7?

Further, the WinSock2 docs make no mention of AF_UNIX.

And my attempt to use it compiles clean, but results in a runtime error (as expected):

#include <winsock2.h> #include <ws2tcpip.h> #include <stdio.h> int main( int argc, char **argv ) { WSADATA wsaData = {0}; int iResult = 0; SOCKET sock = INVALID_SOCKET; if( WSAStartup(MAKEWORD(2, 2), &wsaData) != 0 ) { printf( "WSAStartup failed: %d\n", iResult); return 1; } sock = socket( AF_UNIX, SOCK_DGRAM, IPPROTO_TCP ); if( sock == INVALID_SOCKET ) printf( "socket function failed with error = %d\n", WSAGetLast +Error() ); else { printf( "socket function succeeded\n" ); iResult = closesocket( sock ); if( iResult == SOCKET_ERROR ) { printf( "closesocket failed with error = %d\n", WSAGetLast +Error() ); WSACleanup(); return 1; } } WSACleanup(); return 0; }

Compile/link/run/error:

C:\test>cl /W3 unixDomainSockets.c Ws2_32.lib Microsoft (R) C/C++ Optimizing Compiler Version 15.00.21022.08 for x64 Copyright (C) Microsoft Corporation. All rights reserved. unixDomainSockets.c Microsoft (R) Incremental Linker Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved. /out:unixDomainSockets.exe unixDomainSockets.obj Ws2_32.lib C:\test>unixDomainSockets.exe socket function failed with error = 10047 C:\test>perl -E"say $^E=10047" An address incompatible with the requested protocol was used

So, quite how you are getting away with using *nix domain sockets on Windows I have no idea; but I think that it is more by luck than judgement and probably not doing what you think it is.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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.

Replies are listed 'Best First'.
Re^15: Is there a problem with IPC::Open on Windows 7?
by glasswalk3r (Friar) on Aug 16, 2013 at 15:07 UTC

    Strangely enough, the documentation from Microsoft does not mention neither any domain for some sort of interprocess communication within a single host. Maybe Perl does some sort of emulation when using socketpair in Windows?

    Further testing, even when avoiding using shutdown in the sockets/filehandles the application returns ECONNRESET.

    Is it possible to use Windows named pipes to do the same trick with select? Looks like I'm running out of options.

    UPDATED: just for testing, I changed the code:

    sub _mswin_pipe { my ( $read, $write ) = IO::Socket->socketpair( AF_UNIX, SOCK_STREAM, PF_UNSPEC );

    to:

    sub _mswin_pipe { my ( $read, $write ) = IO::Socket->socketpair( AF_INET, SOCK_STREAM, PF_UNSPEC );

    The result was a disaster: the external program was executed once, communication with the parent process was lost and (since my code is designed to try to fork new children) a lot of srvrmgr.exe were opened.

    Alceu Rodrigues de Freitas Junior
    ---------------------------------
    "You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill
      Is it possible to use Windows named pipes to do the same trick with select? Looks like I'm running out of options.

      Windows Named-pipes (nor anything that isn't an AF_INET socket) don't work with select.

      There is a PeekNamedPipe() function that provides for a similar functionality and could be used to emulate the select-style of operations. It also works on anonymous pipes, which would allow for Windows to emulate *nix style select for most purposes. But someone would have to write and test it.

      But why not simply use AF_INET sockets instead of AF_UNIX sockets?

      As I pointed out earlier, I can attest that these work fine with select.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      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.