简体   繁体   中英

PHP UNIX socket XAMPP

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM