public static boolean tryConnection(String byConnecting, int port, Socket socket) {
		try {
			socket.connect(new InetSocketAddress(byConnecting, port), 2000); // 2 seconds timeout
		} catch (Exception e) {
			return false;
		}
		return true;
	}
Get local host name by connecting to a server.

@param byConnecting the server address to connect.
@param port         the port to connect
@return localhost name. if fails, return "localhost"
ngrinder-core/src/main/java/net/grinder/util/NetworkUtils.java