check for unused ports and then grab one

Brad Tilley bradtilley at
Mon Sep 13 22:31:06 CEST 2004

Instead of me arbitrarily assigning a high port number to a variable, is 
it possible to check for ports that are unused and then randomly assign 
one of them to a variable? Something like this is what I'm thinking:

port = socket.getunusedport()

Any ideas?

More information about the Python-list mailing list