Well, tested the AvailablePortFinder in a Windows 7 machine only to get an unknown Windows Sockets exception.
Finally managed to get what I wanted (a free port number) from the ServerSocket class itself: ServerSocket socket; socket = new ServerSocket(0); socket.setReuseAddress(true); int port = socket.getLocalPort(); socket.close(); socket = null; So far it's working on Mac OS X and Windows 7 although it provides ports on the private/dynamic range. :-/ Zigor. On 16 Jun 2010, at 15:22, Zigor Salvador wrote: > Hi all, > > I'm trying to get the next available port for my acceptor.bind() operation > but the AvailablePortFinder in org.apache.mina.util keeps returning the same > port. > > Application1 @ host -> int freeport = AvailablePortFinder.getNextAvailable(); > > freeport == 1024. > > Application2 @ host -> int freeport = AvailablePortFinder.getNextAvailable(); > > freeport == 1024 !!! > > I'm using MINA 2.0 RC1 and Mac OS X 10.6.4. > > Thanks for any feedback, > > Zigor.
