<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import select <EOL> import pybonjour <EOL> REGTYPE = '<STR_LIT>' <EOL> TIMEOUT = <NUM_LIT:5> <EOL> def BrowseCallback ( sdRef , flags , interfaceIndex , errorCode , serviceName , <EOL> regtype , replyDomain ) : <EOL> if errorCode != pybonjour . kDNSServiceErr_NoError : <EOL> return <EOL> resolved = False <EOL> def ResolveCallback ( sdRef , flags , interfaceIndex , errorCode , fullname , <EOL> hosttarget , port , txtRecord ) : <EOL> global resolved <EOL> if errorCode == pybonjour . kDNSServiceErr_NoError : <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' , hosttarget <EOL> print '<STR_LIT>' , port <EOL> resolved = True <EOL> resolver = pybonjour . DNSServiceResolve ( <EOL> <NUM_LIT:0> , interfaceIndex , serviceName , regtype , replyDomain , ResolveCallback ) <EOL> try : <EOL> while not resolved : <EOL> ready = select . select ( [ resolver ] , [ ] , [ ] , TIMEOUT ) <EOL> if resolver not in ready [ <NUM_LIT:0> ] : <EOL> print '<STR_LIT>' <EOL> break <EOL> pybonjour . DNSServiceProcessResult ( resolver ) <EOL> finally : <EOL> resolver . close ( ) <EOL> def main ( ) : <EOL> browser = pybonjour . DNSServiceBrowse ( regtype = REGTYPE , callBack = BrowseCallback ) <EOL> try : <EOL> ready = select . select ( [ browser ] , [ ] , [ ] ) <EOL> if browser in ready [ <NUM_LIT:0> ] : <EOL> pybonjour . DNSServiceProcessResult ( browser ) <EOL> finally : <EOL> browser . close ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
