Giter Site home page Giter Site logo

socket_create(): Unable to create socket [10047]: An address incompatible with the requested protocol was used about php-websocket HOT 9 OPEN

bloatless avatar bloatless commented on May 15, 2024
socket_create(): Unable to create socket [10047]: An address incompatible with the requested protocol was used

from php-websocket.

Comments (9)

MasumNishat avatar MasumNishat commented on May 15, 2024 3

Hello,

By changing a couple of lines I solved it.
in Server.php

private string $host;
private int $port;

then,

$this->host = $host;
    $this->port = $port;

then,

if (substr(php_uname(), 0, 7) == "Windows"){
        $this->icpSocket = socket_create(AF_INET, SOCK_DGRAM, 0);
        $ipcSocketPath = $this->host;
    } else {
        if (file_exists($ipcSocketPath)) {
            unlink($ipcSocketPath);
        }
        $this->icpSocket = socket_create(AF_UNIX, SOCK_DGRAM, 0);
    }

then,

if (substr(php_uname(), 0, 7) == "Windows") {
        $from = '';
        $port = 0;
        $bytesReceived = socket_recvfrom($this->icpSocket, $buffer, 65536, 0, $from, $port);
    } else {
        $bytesReceived = socket_recvfrom($this->icpSocket, $buffer, 65536, 0, $this->ipcSocketPath);
    }

in Application.php, removed final at line 19

Thanks a lot.

from php-websocket.

nekudo avatar nekudo commented on May 15, 2024

Hello,

I do not use any windows machines so I can not test this but it seems to be a problem with your hosts configuration. Please see: https://stackoverflow.com/questions/2370388/socketexception-address-incompatible-with-requested-protocol

from php-websocket.

suyovj avatar suyovj commented on May 15, 2024

Just found out that SOCK_DGRAM is not supported in Windows. The code has to be modified to enable support for windows.

Reference: https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/

from php-websocket.

nekudo avatar nekudo commented on May 15, 2024

Could you share your changes? Maybe I can include them in the next version.

from php-websocket.

sirj3x avatar sirj3x commented on May 15, 2024

This is my problem and I could not fix any action I had to do and I had to use the old versions

Screenshot (450)

from php-websocket.

nekudo avatar nekudo commented on May 15, 2024

Can you please try to change
$this->icpSocket = socket_create(AF_UNIX, SOCK_DGRAM, 0);
to
$this->icpSocket = socket_create(AF_UNIX, SOCK_STREAM, 0);

and check if that works on a windows machine?

from php-websocket.

cochmedia avatar cochmedia commented on May 15, 2024

Can you please try to change
$this->icpSocket = socket_create(AF_UNIX, SOCK_DGRAM, 0);
to
$this->icpSocket = socket_create(AF_UNIX, SOCK_STREAM, 0);

and check if that works on a windows machine?

No

from php-websocket.

PPhucker avatar PPhucker commented on May 15, 2024

Hello! @MasumNishat solution works. Could you add it in the new version?

from php-websocket.

nekudo avatar nekudo commented on May 15, 2024

@MasumNishat If you create a pull-request I'm happy to merge these changes into a new release.

from php-websocket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.