コード例 #1
0
ファイル: NetworkSocket.php プロジェクト: icicleio/socket
 /**
  * @param resource $socket Stream socket resource.
  * @param bool $autoClose True to close the resource on destruct, false to leave it open.
  */
 public function __construct($socket, bool $autoClose = true)
 {
     parent::__construct($socket, $autoClose);
     try {
         list($this->remoteAddress, $this->remotePort) = getName($socket, true);
         list($this->localAddress, $this->localPort) = getName($socket, false);
     } catch (FailureException $exception) {
         $this->close();
     }
 }
コード例 #2
0
ファイル: Thread.php プロジェクト: icicleio/concurrent
 /**
  * Closes channel and socket if still open.
  */
 private function close()
 {
     if (null !== $this->pipe && $this->pipe->isOpen()) {
         $this->pipe->close();
     }
     if (is_resource($this->socket)) {
         fclose($this->socket);
     }
     $this->thread = null;
     $this->channel = null;
 }
コード例 #3
0
ファイル: Fork.php プロジェクト: icicleio/concurrent
 /**
  * {@inheritdoc}
  */
 public function kill()
 {
     if ($this->isRunning()) {
         // Forcefully kill the process using SIGKILL.
         posix_kill($this->pid, SIGKILL);
     }
     if (null !== $this->pipe && $this->pipe->isOpen()) {
         $this->pipe->close();
     }
     // "Detach" from the process and let it die asynchronously.
     $this->pid = 0;
     $this->channel = null;
 }