Skip to content

Commit

Permalink
Fix macOS server socket
Browse files Browse the repository at this point in the history
  • Loading branch information
solcloud authored Jun 15, 2024
1 parent 5e0ec6d commit ec4e673
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/src/Net/ClueSocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ public function __construct(string $bindAddress)
try {
$this->socket = (new Factory())->createServer($bindAddress);
$this->resource = $this->socket->getResource(); // @phpstan-ignore-line
socket_set_nonblock($this->resource);

Check failure on line 23 in server/src/Net/ClueSocket.php

View workflow job for this annotation

GitHub Actions / composer-check

Parameter #1 $socket of function socket_set_nonblock expects Socket, resource|Socket given.
} catch (Exception $ex) {
throw new NetException($ex->getMessage(), $ex->getCode(), $ex);
}
}

public function sendTo(Client $client, string &$msg): void
{
$ret = @socket_sendto($this->resource, $msg, strlen($msg), MSG_EOR, $client->ip, $client->port);
$ret = @socket_sendto($this->resource, $msg, strlen($msg), 0, $client->ip, $client->port);
if ($ret === false) {
$code = socket_last_error($this->resource);
throw new NetException(socket_strerror($code), $code);
Expand All @@ -36,7 +37,7 @@ public function sendTo(Client $client, string &$msg): void

public function receive(?string &$peerAddress, ?int &$peerPort, int $readMaxBytes = 100): ?string
{
$ret = @socket_recvfrom($this->resource, $buffer, $readMaxBytes, MSG_DONTWAIT, $peerAddress, $peerPort);
$ret = @socket_recvfrom($this->resource, $buffer, $readMaxBytes, 0, $peerAddress, $peerPort);
if ($ret === false) {
$code = socket_last_error($this->resource);
if ($code !== SOCKET_EWOULDBLOCK) {
Expand Down

0 comments on commit ec4e673

Please sign in to comment.