Skip to content

GB spoils CData when returning from a method. It's normal? #28

@interposition

Description

@interposition

Hello, code example:

Class Test
{
   public function getSocket(string $host, int $port): Socket
   {
        $cast = $this->getSockAddr($host, $port);
         // ...
         // bind socket from ffi
   }

   private function getSockAddr(string $host, int $port): CData
   {
      $port = (string)$port;
      $addr = $this->ffi->new('struct sockaddr_in', false);

      $addr->sin_family   = self::AF_INET;
      $addr->sin_port     = $this->ffi->htons($port);

      $this->fillInAddrFromHost($addr, $host);

      return $this->ffi->cast("const struct sockaddr", $addr);
   }

   private function fillInAddrFromHost(CData $addr, string $host): void
   {
        $inAddr = inet_pton($host);
        FFI::memcpy($addr->sin_addr, $inAddr, strlen($inAddr));
    }
}

If sockaddr_in create with persistent = true - bind return ENODATA.
It's normal? If execute all the code in one method - everything is fine with persistent = true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions