# File lib/net/ber/ber_parser.rb, line 152
  def read_ber(syntax = nil)
    # TODO: clean this up so it works properly with partial packets coming
    # from streams that don't block when we ask for more data (like
    # StringIOs). At it is, this can throw TypeErrors and other nasties.

    id = getbyte or return nil  # don't trash this value, we'll use it later
    content_length = read_ber_length

    if -1 == content_length
      raise Net::BER::BerError, "Indeterminite BER content length not implemented."
    else
      data = read(content_length)
    end

    parse_ber_object(syntax, id, data)
  end