Exemplo n.º 1
0
 /** {@inheritdoc} */
 public function open($address, $context = null)
 {
     $this->resource = $this->createSocketResource($address, $context ?: stream_context_get_default());
     $result = false;
     if (is_resource($this->resource)) {
         $result = true;
         $this->remoteAddress = $address;
         // https://bugs.php.net/bug.php?id=51056
         stream_set_blocking($this->resource, 0);
         // https://bugs.php.net/bug.php?id=52602
         stream_set_timeout($this->resource, 0, 0);
         $this->ioInterface = $this->createIoInterface($this->resolveSocketType(), $address);
         $this->context->reset();
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Read unhandled data if there is something from the previous operation
  *
  * @param FramePickerInterface $picker Frame picker to use
  * @param Context              $context Socket context
  * @param bool                 $isOutOfBand Flag if it is out-of-band data
  *
  * @return bool Flag whether it is the end of the frame
  */
 private function handleUnreadData(FramePickerInterface $picker, Context $context, $isOutOfBand)
 {
     $unhandledData = $context->getUnreadData($isOutOfBand);
     if ($unhandledData) {
         $context->setUnreadData($picker->pickUpData($unhandledData, $this->getRemoteAddress()), $isOutOfBand);
     }
     return $picker->isEof();
 }