#NEWLINE# def _get_free_listen_port( self ) : #NEWLINE# #INDENT# '\n        Find a free local TCP port that we can listen on,\n        we want this to be able to give to mosquitto.\n        ' #NEWLINE# s = socket . socket ( ) #NEWLINE# s . bind ( ( 'localhost' , 0 ) ) #NEWLINE# chosen_port = s . getsockname ( ) [ 1 ] #NEWLINE# s . close ( ) #NEWLINE# return chosen_port