/**
  * Wait until some data is retrieved from the socket.
  *
  * AMQPTimeoutException can be raised if the timeout is set
  *
  * @throws \PhpAmqpLib\Exception\AMQPTimeoutException
  */
 protected function wait()
 {
     if ($this->timeout == 0) {
         return;
     }
     // wait ..
     list($sec, $usec) = MiscHelper::splitSecondsMicroseconds($this->timeout);
     $result = $this->io->select($sec, $usec);
     if ($result === false) {
         throw new AMQPRuntimeException(sprintf("An error occurs", $this->timeout));
     }
     if ($result === 0) {
         throw new AMQPTimeoutException(sprintf("A timeout of %ds occurs while waiting for incoming data", $this->timeout));
     }
 }
Example #2
0
 /**
  * Waits until some data is retrieved from the socket.
  *
  * AMQPTimeoutException can be raised if the timeout is set
  *
  * @throws \PhpAmqpLib\Exception\AMQPTimeoutException
  */
 protected function wait()
 {
     if ($this->timeout == 0) {
         return;
     }
     // wait ..
     list($sec, $usec) = MiscHelper::splitSecondsMicroseconds($this->timeout);
     $result = $this->io->select($sec, $usec);
     if ($result === false) {
         throw new AMQPRuntimeException('A network error occured while awaiting for incoming data');
     }
     if ($result === 0) {
         throw new AMQPTimeoutException(sprintf('The connection timed out after %s sec while awaiting incoming data', $this->getTimeout()));
     }
 }