Here you can find the source of getFreePortNoSych()
Parameter | Description |
---|---|
Exception | Any exception |
protected static int getFreePortNoSych() throws Exception
//package com.java2s; //License from project: Apache License import java.net.ServerSocket; public class Main { /**//www. j av a 2 s .co m * Returns a free port * * @return The free port * @throws Exception * Any exception */ protected static int getFreePortNoSych() throws Exception { ServerSocket socket = new ServerSocket(0); int port = socket.getLocalPort(); socket.close(); return port; } }