def make_socket():
    '''Creates a socket suitable for SSDP searches.

    The socket will have a default timeout of 0.2 seconds (this works well for
    the :py:func:search function which interleaves sending requests and reading
    responses.
    '''
    mreq = struct.pack("4sl", socket.inet_aton(MCAST_IP), socket.INADDR_ANY)
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    sock.bind(('', MCAST_PORT))
    sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
    sock.settimeout(0.2)
    return sock
def make_socket ( ) : mreq = struct . pack ( "4sl" , socket . inet_aton ( MCAST_IP ) , socket . INADDR_ANY ) sock = socket . socket ( socket . AF_INET , socket . SOCK_DGRAM , socket . IPPROTO_UDP ) sock . setsockopt ( socket . SOL_SOCKET , socket . SO_REUSEADDR , 1 ) sock . bind ( ( '' , MCAST_PORT ) ) sock . setsockopt ( socket . IPPROTO_IP , socket . IP_ADD_MEMBERSHIP , mreq ) sock . settimeout ( 0.2 ) return sock
Creates a socket suitable for SSDP searches.

    The socket will have a default timeout of 0.2 seconds (this works well for
    the :py:func:search function which interleaves sending requests and reading
    responses.