How to pick a free port number in python?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1365265/on-localhost-how-to-pick-a-free-port-number">On localhost, how to pick a free port number?</a>  </p>
</blockquote>



<p>My requirement is different from this question.</p>

<p><a href="http://stackoverflow.com/questions/1365265/on-localhost-how-to-pick-a-free-port-number">On localhost, how to pick a free port number?</a></p>

<p>I am writing a test setup of another process using python. The other process needs a port number to be passed (say as a command line parameter). I cannot hard-code some random port number because many users usually would run same test in the same box. Now, how do I select a free port in python? </p>

<p><em>Edit:</em></p>

<p>I am not creating a socket in python. I just need to pass a number to some other process as a command line argument.</p>

<p>From DRH's answer, 
I could create a dummy socket, get its port number, close it and pass to the actual process. Is there any better way to do this?</p>
