Skip to content

Commit

Permalink
use configured stream capabilities in the Sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptouuuu committed Feb 25, 2023
1 parent 8d2f472 commit d65e53c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,10 @@

- `Innmind\OperatingSystem\OperatingSystem\Unix::config()` (declared as `internal`)

### Changed

- `Innmind\OperatingSystem\Sockets\Unix` now uses the stream `Capabilities` from the `Config`

## 3.6.0 - 2023-02-11

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/OperatingSystem/Unix.php
Expand Up @@ -94,7 +94,7 @@ public function ports(): Ports

public function sockets(): Sockets
{
return $this->sockets ??= Sockets\Unix::of();
return $this->sockets ??= Sockets\Unix::of($this->config);
}

public function remote(): Remote
Expand Down
26 changes: 20 additions & 6 deletions src/Sockets/Unix.php
Expand Up @@ -3,7 +3,10 @@

namespace Innmind\OperatingSystem\Sockets;

use Innmind\OperatingSystem\Sockets;
use Innmind\OperatingSystem\{
Sockets,
Config,
};
use Innmind\Socket\{
Address\Unix as Address,
Server,
Expand All @@ -15,13 +18,16 @@

final class Unix implements Sockets
{
private function __construct()
private Config $config;

private function __construct(Config $config)
{
$this->config = $config;
}

public static function of(): self
public static function of(Config $config = null): self
{
return new self;
return new self($config ?? Config::of());
}

public function open(Address $address): Maybe
Expand All @@ -45,9 +51,17 @@ public function connectTo(Address $address): Maybe
public function watch(ElapsedPeriod $timeout = null): Watch
{
if (\is_null($timeout)) {
return Watch\Select::waitForever();
return $this
->config
->streamCapabilities()
->watch()
->waitForever();
}

return Watch\Select::timeoutAfter($timeout);
return $this
->config
->streamCapabilities()
->watch()
->timeoutAfter($timeout);
}
}

0 comments on commit d65e53c

Please sign in to comment.