Example #1
0
 protected function resolveAddress() : \Generator
 {
     if ($this->protocol == 'unix') {
         return [$this->peer];
     }
     // Do a substring split here because IPv6 addresses may contain colons.
     $index = \strrpos($this->peer, ':');
     if ($index !== false) {
         $parts = [\substr($this->peer, 0, $index), \substr($this->peer, $index + 1)];
         $port = \array_pop($parts);
     }
     if (empty($parts)) {
         throw new SocketException(\sprintf('Missing port in peer "%s"', $this->peer));
     }
     $address = (yield ($this->resolver ?? LoopConfig::currentHostResolver())->resolve($parts[0]));
     $resolved = [];
     foreach ($address as $addr) {
         $resolved[] = \sprintf('%s:%u', $addr, $port);
     }
     return $resolved;
 }