<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def responses_from_socket(sock, timeout=10):
    '''Yield SSDP search responses and advertisements from the provided socket.

    Args:
        sock: A socket suitable for use to send a broadcast message - preferably
            one created by :py:func:`make_socket`.
        timeout (int / float): Overall time in seconds for how long to wait for
            before no longer listening for responses.

    Yields:
        dict of string -> string: Case-insensitive dictionary of header name to
        header value pairs extracted from the response.
    '''
    now = time.time()
    give_up_by = now + timeout

    while now < give_up_by:
        try:
            data = sock.recv(1024)
        except socket.timeout:
            now = time.time()
            continue

        # We handle either search responses or announcements.
        for data_prefix in [
            b'HTTP/1.1 200 OK',
            b'NOTIFY * HTTP/1.1',
        ]:
            if data[:len(data_prefix)] == data_prefix:
                break
        else:
            now = time.time()
            continue

        yield decode_response(data)

        now = time.time()
        continue