gets a frame from the socket and returns the parsed response.
768986
def one_frame
      size = @socket.read(4)
      raise SocketError, @socket.eof? ? 'Connection closed by remote server' : 'Error reading frame from remote server' if size.nil?
      size = size.unpack('N')[0]
      @recv_frame = @socket.read(size - 4)
      recv_frame_to_xml
    end
98125
def next_frame_header(socket):
    
    try:
        data = read_exactly(socket, 8)
    except SocketError:
        return (-1, -1)

    stream, actual = struct.unpack('>BxxxL', data)
    return (stream, actual)
1253807
def get_frame(self, in_data, frame_count, time_info, status):
		
		while self.keep_listening:
			try:
				frame = self.queue.get(False, timeout=queue_timeout)
				return (frame, pyaudio.paContinue)
			except Empty:
				pass
		return (None, pyaudio.paComplete)
783527
def from_frame(klass, frame, connection):
        
        event = frame.headers['new']
        data = json.loads(frame.body)
        info = data['info']
        build = Build.fromDict(info)
        build.connection = connection
        return klass(build, event)
393263
def _get_framed(self, buf, offset, insert_payload):
    
    header_offset = offset + self._header_len
    self.length = insert_payload(buf, header_offset, self.payload)
    struct.pack_into(self._header_fmt,
                     buf,
                     offset,
                     self.preamble,
                     self.msg_type,
                     self.sender,
                     self.length)
    crc_offset = header_offset + self.length
    preamble_bytes = 1
    crc_over_len = self._header_len + self.length - preamble_bytes
    self.crc = crc16jit(buf, offset+1, 0, crc_over_len)
    struct.pack_into(self._crc_fmt, buf, crc_offset, self.crc)
    length = preamble_bytes + crc_over_len + self._crc_len
    return length
180551
def parse_frame(self, buf: bytes) -> List[Tuple[bool, Optional[int],
                                                    bytearray,
                                                    Optional[bool]]]:
        """"""
        frames = []
        if self._tail:
            buf, self._tail = self._tail + buf, b''

        start_pos = 0
        buf_length = len(buf)

        while True:
            # read header
            if self._state == WSParserState.READ_HEADER:
                if buf_length - start_pos >= 2:
                    data = buf[start_pos:start_pos+2]
                    start_pos += 2
                    first_byte, second_byte = data

                    fin = (first_byte >> 7) & 1
                    rsv1 = (first_byte >> 6) & 1
                    rsv2 = (first_byte >> 5) & 1
                    rsv3 = (first_byte >> 4) & 1
                    opcode = first_byte & 0xf

                    # frame-fin = %x0 ; more frames of this message follow
                    #           / %x1 ; final frame of this message
                    # frame-rsv1 = %x0 ;
                    #    1 bit, MUST be 0 unless negotiated otherwise
                    # frame-rsv2 = %x0 ;
                    #    1 bit, MUST be 0 unless negotiated otherwise
                    # frame-rsv3 = %x0 ;
                    #    1 bit, MUST be 0 unless negotiated otherwise
                    #
                    # Remove rsv1 from this test for deflate development
                    if rsv2 or rsv3 or (rsv1 and not self._compress):
                        raise WebSocketError(
                            WSCloseCode.PROTOCOL_ERROR,
                            'Received frame with non-zero reserved bits')

                    if opcode > 0x7 and fin == 0:
                        raise WebSocketError(
                            WSCloseCode.PROTOCOL_ERROR,
                            'Received fragmented control frame')

                    has_mask = (second_byte >> 7) & 1
                    length = second_byte & 0x7f

                    # Control frames MUST have a payload
                    # length of 125 bytes or less
                    if opcode > 0x7 and length > 125:
                        raise WebSocketError(
                            WSCloseCode.PROTOCOL_ERROR,
                            'Control frame payload cannot be '
                            'larger than 125 bytes')

                    # Set compress status if last package is FIN
                    # OR set compress status if this is first fragment
                    # Raise error if not first fragment with rsv1 = 0x1
                    if self._frame_fin or self._compressed is None:
                        self._compressed = True if rsv1 else False
                    elif rsv1:
                        raise WebSocketError(
                            WSCloseCode.PROTOCOL_ERROR,
                            'Received frame with non-zero reserved bits')

                    self._frame_fin = bool(fin)
                    self._frame_opcode = opcode
                    self._has_mask = bool(has_mask)
                    self._payload_length_flag = length
                    self._state = WSParserState.READ_PAYLOAD_LENGTH
                else:
                    break

            # read payload length
            if self._state == WSParserState.READ_PAYLOAD_LENGTH:
                length = self._payload_length_flag
                if length == 126:
                    if buf_length - start_pos >= 2:
                        data = buf[start_pos:start_pos+2]
                        start_pos += 2
                        length = UNPACK_LEN2(data)[0]
                        self._payload_length = length
                        self._state = (
                            WSParserState.READ_PAYLOAD_MASK
                            if self._has_mask
                            else WSParserState.READ_PAYLOAD)
                    else:
                        break
                elif length > 126:
                    if buf_length - start_pos >= 8:
                        data = buf[start_pos:start_pos+8]
                        start_pos += 8
                        length = UNPACK_LEN3(data)[0]
                        self._payload_length = length
                        self._state = (
                            WSParserState.READ_PAYLOAD_MASK
                            if self._has_mask
                            else WSParserState.READ_PAYLOAD)
                    else:
                        break
                else:
                    self._payload_length = length
                    self._state = (
                        WSParserState.READ_PAYLOAD_MASK
                        if self._has_mask
                        else WSParserState.READ_PAYLOAD)

            # read payload mask
            if self._state == WSParserState.READ_PAYLOAD_MASK:
                if buf_length - start_pos >= 4:
                    self._frame_mask = buf[start_pos:start_pos+4]
                    start_pos += 4
                    self._state = WSParserState.READ_PAYLOAD
                else:
                    break

            if self._state == WSParserState.READ_PAYLOAD:
                length = self._payload_length
                payload = self._frame_payload

                chunk_len = buf_length - start_pos
                if length >= chunk_len:
                    self._payload_length = length - chunk_len
                    payload.extend(buf[start_pos:])
                    start_pos = buf_length
                else:
                    self._payload_length = 0
                    payload.extend(buf[start_pos:start_pos+length])
                    start_pos = start_pos + length

                if self._payload_length == 0:
                    if self._has_mask:
                        assert self._frame_mask is not None
                        _websocket_mask(self._frame_mask, payload)

                    frames.append((
                        self._frame_fin,
                        self._frame_opcode,
                        payload,
                        self._compressed))

                    self._frame_payload = bytearray()
                    self._state = WSParserState.READ_HEADER
                else:
                    break

        self._tail = buf[start_pos:]

        return frames
1331094
def recv_frame
        header = @sock.read(HEADER_LEN)

        if header.nil? && @sock.eof?
          raise ServerError, "Connection terminated by remote host"
        elsif header.nil?
          raise ServerError, "Failed to read header from remote host"
        else
          len = header.unpack('N')[0]

          raise ServerError, "Bad frame header from server, should be greater than #{HEADER_LEN}" unless len > HEADER_LEN
          @sock.read(len - HEADER_LEN)
        end
      end
562794
def get_frame(self, index=None, onset=None):
        ''' 
        '''
        if onset:
            index = int(onset * self.fps)

        return super(VideoStim, self).get_frame(index)
166992
def from_frame(cls, frame):
        """"""
        message = cls()

        # Check checksum first
        checksum = 0
        for i in range(0, len(frame) - 1):
            checksum += frame[i]

        if (checksum % 0x100) != frame[len(frame) - 1]:
            raise KNXException('Checksum error in frame {}, '
                               'expected {} but got {}'
                               .format(tohex(frame), frame[len(frame) - 1],
                                       checksum % 0x100))

        message.repeat = (frame[0] >> 5) & 0x01
        message.priority = (frame[0] >> 2) & 0x03
        message.src_addr = (frame[1] << 8) + frame[2]
        message.dst_addr = (frame[3] << 8) + frame[4]
        message.multicast = (frame[5] >> 7)
        message.routing = (frame[5] >> 4) & 0x03
        message.length = frame[5] & 0x0f
        message.data = frame[6:-1]

        if len(message.data) + 1 != message.length:
            raise KNXException(
                'Frame {} has not the correct length'.format(tohex(frame)))

        return message
567081
def send_frame(self, frame):
        
        packed = frame.pack()
        if self.debug:  # pragma: no cover
            self.log.debug("SEND: %r" % packed)
        self.request.sendall(packed)
539476
def parse_response(self, block=True, timeout=0):
        ""
        connection = self.connection
        if connection is None:
            raise RuntimeError(
                'pubsub connection not set: '
                'did you forget to call subscribe() or psubscribe()?')
        if not block and not connection.can_read(timeout=timeout):
            return None
        return self._execute(connection, connection.read_response)
10909
public String getFrameData() {
        if (SockJsFrameType.OPEN == getType() || SockJsFrameType.HEARTBEAT == getType()) {
            return null;
        } else {
            return getContent().substring(1);
        }
    }
250008
def receive_frame(frame)
      validate_received_frame(frame)
      consume_recv_window(frame)

      case frame
      when Frame::Data then         receive_data(frame)
      when Frame::Headers then      receive_headers(frame)
      when Frame::Priority then     receive_priority(frame)
      when Frame::RstStream then    receive_rst_stream(frame)
      when Frame::WindowUpdate then receive_window_update(frame)
      when Frame::Continuation then receive_continuation(frame)
      when Frame::PushPromise then  receive_push_promise(frame)
      when Frame::Ping, Frame::Goaway, Frame::Settings
        raise RemoteConnectionError.new(:protocol_error) # stream_id MUST be 0x00
      else
        # MUST ignore unknown frame
      end
    rescue RemoteStreamError => e
      callback(:stream_error, e)
      send_immediately Frame::RstStream.new(id, e.http2_error_type)
      close
    end
402082
public Header readFrame() throws BitstreamException
	{
		Header result = null;
		try
		{
			result = readNextFrame();
			// E.B, Parse VBR (if any) first frame.
			if (firstframe == true)
			{
				result.parseVBR(frame_bytes);
				firstframe = false;
			}			
		}
		catch (BitstreamException ex)
		{
			if ((ex.getErrorCode()==INVALIDFRAME))
			{
				// Try to skip this frame.
				//System.out.println("INVALIDFRAME");
				try
				{
					closeFrame();
					result = readNextFrame();
				}
				catch (BitstreamException e)
				{
					if ((e.getErrorCode()!=STREAM_EOF))
					{
						// wrap original exception so stack trace is maintained.
						throw newBitstreamException(e.getErrorCode(), e);
					}
				}
			}
			else if ((ex.getErrorCode()!=STREAM_EOF))
			{
				// wrap original exception so stack trace is maintained.
				throw newBitstreamException(ex.getErrorCode(), ex);
			}
		}
		return result;
	}
831504
def _frame_received(self, frame):
        
        try:
            self._rx_frames[frame["frame_id"]] = frame
        except KeyError:
            # Has no frame_id, ignore?
            pass
        _LOGGER.debug("Frame received: %s", frame)
        # Give the frame to any interested functions
        for handler in self._rx_handlers:
            handler(frame)
1007457
def data_received(self, data):
        

        # First, add the data to the receive buffer
        self._recv_buf += data

        # Now, pass all frames we can find to the client protocol
        while self._recv_buf and not self._recv_paused:
            try:
                # Extract one frame
                frame = self._recv_framer.to_frame(self._recv_buf,
                                                   self._recv_state)
            except exc.NoFrames:
                # There's data in the buffer, but no complete frames
                break

            # Now call the client protocol's frame_received() method
            self._client.frame_received(frame)
1282100
function frame(frame) {
    frame.__comments = [];
    frame.__proto__ = {
        __proto__: frame.__proto__,

        /**
         * Returns the contents of the file for this frame as an
         * array of lines, and optionally as a clamped range of lines.
         *
         * NOTE: lines are 0-indexed
         *
         * @throws RangeError if length is less than or equal to 0
         * @param  start
         * @param  length
         * @returns {Array|undefined}
         */

        getFileLines: function (start, length) {
            if (!start) {
                start = 0;
            }
            var contents = this.getFileContents();
            if (null !== contents) {
                var lines = (contents).split("\n");

                // Get a subset of lines from $start to $end
                if (length !== null) {
                    start = parseInt(start);
                    length = parseInt(length);
                    if (start < 0) {
                        start = 0;
                    }

                    if (length <= 0) {
                        throw new RangeError(
                            "length cannot be lower or equal to 0"
                        );
                    }

                    lines = lines.slice(start, start + length);
                }

                return lines;
            }
        },

        /**
         * Returns the full contents of the file for this frame, if it's known.
         *
         * @returns {*}
         */
        getFileContents: function () {
            var filePath = this.getFileName();
            if (!this.__fileContentsCache && filePath) {
                // Leave the stage early when 'Unknown' is passed
                // this would otherwise raise an exception when
                // open_basedir is enabled.
                if (filePath === "Unknown") {
                    return null;
                }

                // Return null if the file doesn't actually exist.
                if (!fs.existsSync(filePath)) {
                    if (process.env.NVM_DIR && process.versions.node) {
                        filePath = path.join(process.env.NVM_DIR, 'src/node-v' + process.versions.node, 'lib', filePath);
                        if (!fs.existsSync(filePath)) {
                            return null;
                        }
                    } else {
                        return null;
                    }
                }

                this.__fileContentsCache = fs.readFileSync(filePath, 'utf-8');
            }

            return this.__fileContentsCache;
        },

        /**
         * Adds a comment to this frame, that can be received and used by other handlers. For example, the PrettyPage
         * handler can attach these comments under the code for each frame.
         * An interesting use for this would be, for example, code analysis & annotations.
         *
         * @param {String} comment
         * @param {String} context Optional string identifying the origin of the comment
         */
        addComment: function (comment, context) {
            context = context || 'global';
            this.__comments.push({
                'comment': comment,
                'context': context
            });
        },

        /**
         * Returns all comments for this frame. Optionally allows a filter to only retrieve comments from a specific
         * context.
         *
         * @param  {String} filter
         * @returns {Array}
         */
        getComments: function (filter) {
            if (!filter) {
                filter = null;
            }
            var comments = this.__comments;

            if (filter !== null) {
                comments = comments.filter(function (c) {
                    return c.context === filter;
                });
            }

            return comments;
        }

    };
    return frame;
}