1

I am using XAMPP v3.2.1 with PHP 5.5 on Windows 7 Professional. Everything should be OK, but this piece of code just doesn't wants to work.

protected function _get_socket()
{
    if (($sock = @socket_create(AF_UNIX, SOCK_STREAM, 0)) === FALSE) {
        throw new VlaChatSe('socket_create', socket_last_error());
    }
    return $sock;
}

Whatever I do, the exception gets thrown. I've read that for UNIX sockets I need the IP protocol (0), although I tried TCP and UDP too. I tried SOCK_DGRAM instead of SOCK_STREAM and no luck so far, I also tried to reinstall XAMPP with php 5.4 version - still no luck. My options are exhausted, so I thought that you can help me... However I suppose that UNIX sockets does not work on Windows, because similar code worked fine in *nix environment.

1 Answer 1

2

Windows doesn't implement Unix domain sockets so you'll have to use an alternative. The closest equivalent is named pipes, but I don't know to use them from PHP. A workable alternative could be TCP sockets bound to the loopback interface, though they are associated with a port number and not a file name.

Sign up to request clarification or add additional context in comments.

2 Comments

Is this documented anywhere?
I can't find the definitive list of address and protocol families that winsock supports so I have no proof of there not being support, but if windows did have Unix domain sockets it would be well known and it should be documented here: msdn.microsoft.com/en-us/library/windows/desktop/… It's hard to prove a negative...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.