#NEWLINE# def get_unused_port( host = '127.0.0.1' , family = socket . AF_INET , socktype = socket . SOCK_STREAM ) : #NEWLINE# #INDENT# tempsock = socket . socket ( port , socktype ) #NEWLINE# tempsock . bind ( ( host , 0 ) ) #NEWLINE# port = tempsock . getsockname ( ) [ 1 ] #NEWLINE# tempsock . close ( ) #NEWLINE# del tempsock #NEWLINE# return port