code: protected function createSocket()
      {
          $this->receivedBytes = 0;
          $this->receivedPackets = 0;
          $this->transmittedBytes = 0;
          $this->transmittedPackets = 0;
          switch (get_class($this)) {
              case TcpClient::class:
                  $type = SOCK_STREAM;
                  $protocol = SOL_TCP;
                  break;
              case UdpClient::class:
                  $type = SOCK_DGRAM;
                  $protocol = SOL_UDP;
                  break;
              default:
                  throw new \LogicException('Other protocols not supported.');
          }
          if (!($this->socket = socket_create($this->socketDomain, $type, $protocol))) {
              $this->errorHandler->handleError();
          } else {
              $this->errorHandler->setSocket($this->socket);
          }
          $this->connectionResource = new SocketConnectionResource($this->socket);
      }
docs: Создаёт сокет.
  
  @throws ConnectionException