コード例 #1
0
ファイル: TcpClient.php プロジェクト: slrondon/MikrotikCenter
 /**
  * Receives data from the server.
  * 
  * Receives data from the server as a string.
  * 
  * @param int    $length The number of bytes to receive.
  * @param string $what   Descriptive string about what is being received
  *     (used in exception messages).
  * 
  * @return string The received content.
  */
 public function receive($length, $what = 'data')
 {
     if (false === ($previousState = $this->lock(self::DIRECTION_RECEIVE)) && $this->persist) {
         throw $this->createException('Unable to obtain receiving lock', 9);
     }
     try {
         $result = parent::receive($length, $what);
     } catch (E $e) {
         $this->lock($previousState, true);
         throw $e;
     }
     $this->lock($previousState, true);
     return $result;
 }