ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald McLean <dmcl...@stsci.edu>
Subject Re: Finding an available port number
Date Tue, 03 May 2011 00:01:24 GMT
Depends on what you're trying to do. Most programming environments have 
a way to create a socket on an available port number.

For example (from JavaDoc for java.net.ServerSocket):

public ServerSocket(int port)
              throws IOException

     Creates a server socket, bound to the specified port. A port of 0 
creates a socket on any free port.

On 5/2/11 5:30 PM, Daniel Becroft wrote:
> Hi,
>
> Is there a task or script that can be used to generate a (random) port
> number that is known to be available? I'm trying to setup some server
> instances for testing purposes, and I'd prefer not to hard-code port
> numbers.
>
> I'm running on Windows, so I don't have awk/sed available by default,
> either.


Mime
View raw message