original_string: public static function blockingRead($socket, $timeout = 500.0)
      {
          static $cmds = array();
  
          $tv_sec = floor(($timeout % 1000));
          $tv_usec = ($timeout * 1000);
  
          $start = microtime(true);
          while (count($cmds) == 0) {
              if (((microtime(true) - $start) * 1000) > $timeout) {
                  throw new Exception('Blocking read timed out');
              }
  
              $write = null;
              $except = null;
              $read = array($socket);
  
              socket_select($read, $write, $except, $tv_sec, $tv_usec);
              foreach ($read as $s) {
                  $cmds[] = self::read($s);
              }
          }
  
          return array_shift($cmds);
      }
code: public static function blockingRead($socket, $timeout = 500.0)
      {
          static $cmds = array();
  
          $tv_sec = floor(($timeout % 1000));
          $tv_usec = ($timeout * 1000);
  
          $start = microtime(true);
          while (count($cmds) == 0) {
              if (((microtime(true) - $start) * 1000) > $timeout) {
                  throw new Exception('Blocking read timed out');
              }
  
              $write = null;
              $except = null;
              $read = array($socket);
  
              socket_select($read, $write, $except, $tv_sec, $tv_usec);
              foreach ($read as $s) {
                  $cmds[] = self::read($s);
              }
          }
  
          return array_shift($cmds);
      }
code_tokens: public static function blockingRead ( $ socket , $ timeout = 500.0 ) { static $ cmds = array ( ) ; $ tv_sec = floor ( ( $ timeout % 1000 ) ) ; $ tv_usec = ( $ timeout * 1000 ) ; $ start = microtime ( true ) ; while ( count ( $ cmds ) == 0 ) { if ( ( ( microtime ( true ) - $ start ) * 1000 ) > $ timeout ) { throw new Exception ( 'Blocking read timed out' ) ; } $ write = null ; $ except = null ; $ read = array ( $ socket ) ; socket_select ( $ read , $ write , $ except , $ tv_sec , $ tv_usec ) ; foreach ( $ read as $ s ) { $ cmds [ ] = self :: read ( $ s ) ; } } return array_shift ( $ cmds ) ; }
docstring: Blocking socket read.
  
  @param resource $socket  The socket to read from
  @param float    $timeout The timeout for the read
  
  @throws \MHlavac\Gearman\Exception on timeouts
  
  @return array
docstring_tokens: Blocking socket read .