Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top