def _read_socket(socket):
<EOL>while True:<EOL><INDENT>try:<EOL><INDENT>payload_type, payload_size = _read_header(socket)<EOL>if payload_size < <NUM_LIT:0>:<EOL><INDENT>break<EOL><DEDENT>for data in _read_payload(socket, payload_size):<EOL><INDENT>yield payload_type, data<EOL><DEDENT><DEDENT>except timeout:<EOL><INDENT>LOG.debug("<STR_LIT>")<EOL><DEDENT>except SocketError:<EOL><INDENT>break<EOL><DEDENT><DEDENT>
The stdout and stderr data from the container multiplexed into one stream of response from the Docker API.
It follows the protocol described here https://docs.docker.com/engine/api/v1.30/#operation/ContainerAttach.
The stream starts with a 8 byte header that contains the frame type and also payload size. Follwing that is the
actual payload of given size. Once you read off this payload, we are ready to read the next header.

This method will follow this protocol to read payload from the stream and return an iterator that returns
a tuple containing the frame type and frame data. Callers can handle the data appropriately based on the frame
type.

    Stdout => Frame Type = 1
    Stderr => Frame Type = 2


Parameters
----------
socket
    Socket to read responses from

Yields
-------
int
    Type of the stream (1 => stdout, 2 => stderr)
str
    Data in the stream