예제 #1
0
파일: mdns.py 프로젝트: okoeroo/pyairplay
 def close(self):
     """Ends the background threads, and prevent this instance from
     servicing further queries."""
     if globals()['_GLOBAL_DONE'] == 0:
         globals()['_GLOBAL_DONE'] = 1
         self.notifyAll()
         self.engine.notify()
         self.unregisterAllServices()
         mcastsocket.leave_group( self.socket, dns._MDNS_ADDR )
         self.socket.close()
예제 #2
0
파일: ssdp.py 프로젝트: okoeroo/pyairplay
def main(ip):
    """Create a multicast socket, send a message, check it comes back"""
    port = PORT
    sock = mcastsocket.create_socket( (ip,port), loop=False )
    mcastsocket.join_group( sock, GROUP )
    try:
        payload = query % locals()
        while True:
            sock.sendto( payload, 0, (GROUP,PORT))
            #print 'Waiting for responses'
            rs,wr,xs = select.select( [sock],[],[], 20.0 )
            if rs:
                data, addr = sock.recvfrom( 2000 )
                handle( sock, data, addr )
        return 1
    finally:
        mcastsocket.leave_group( sock, GROUP )