private static boolean canConnect(int port) {

		Socket socket = null;
		try {
			SocketAddress sockaddr = new InetSocketAddress(LOCALHOST, port);
			socket = new Socket();
			socket.connect(sockaddr, 500);
			return true;
		}
		catch (UnknownHostException e) {
			return true; // defer error
		}
		catch (IOException e) {
			return false; // connect error?
		}
		finally {
			if (socket != null) {
				try {
					socket.close();
				}
				catch (IOException e) {
					// ignore
				}
			}
		}
	}
Start a server instance on the specified port.
This server must be disposed before attempting to create another.
@param dirPath server root directory
@param port RMI registry port, 0 indicates that default port should be used
@param authMode authentication mode (-1 for no authentication)
@param enableAltLoginName if true enable alternate login name
@param enableSSHAuthentication if true SSH authentication will be enabled
@param enableAnonymousAuthentication if true anonymous usage is allowed
@throws IOException
Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/server/remote/ServerTestUtil.java