Skip to content

Commit 5c596b2

Browse files
authored
Merge pull request #42 from ineternet/master
Windows fix (#27)
2 parents cc7d6d8 + 6edb79d commit 5c596b2

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

Diff for: src/Server.php

+16-5
Original file line numberDiff line numberDiff line change
@@ -598,10 +598,15 @@ public function writeBuffer($resource, string $string): int
598598
*/
599599
private function openIPCSocket(string $ipcSocketPath): void
600600
{
601-
if (file_exists($ipcSocketPath)) {
602-
unlink($ipcSocketPath);
603-
}
604-
$this->icpSocket = socket_create(AF_UNIX, SOCK_DGRAM, 0);
601+
if (substr(php_uname(), 0, 7) == "Windows"){
602+
$this->icpSocket = socket_create(AF_INET, SOCK_DGRAM, 0);
603+
$ipcSocketPath = $this->host;
604+
} else {
605+
if (file_exists($ipcSocketPath)) {
606+
unlink($ipcSocketPath);
607+
}
608+
$this->icpSocket = socket_create(AF_UNIX, SOCK_DGRAM, 0);
609+
}
605610
if ($this->icpSocket === false) {
606611
throw new \RuntimeException('Could not open ipc socket.');
607612
}
@@ -630,7 +635,13 @@ private function openIPCSocket(string $ipcSocketPath): void
630635
private function handleIPC(): void
631636
{
632637
$buffer = '';
633-
$bytesReceived = socket_recvfrom($this->icpSocket, $buffer, 65536, 0, $this->ipcSocketPath);
638+
if (substr(php_uname(), 0, 7) == "Windows") {
639+
$from = '';
640+
$port = 0;
641+
$bytesReceived = socket_recvfrom($this->icpSocket, $buffer, 65536, 0, $from, $port);
642+
} else {
643+
$bytesReceived = socket_recvfrom($this->icpSocket, $buffer, 65536, 0, $this->ipcSocketPath);
644+
}
634645
if ($bytesReceived === false) {
635646
return;
636647
}

0 commit comments

Comments
 (0)