List of utility methods to do HTTP Port Find
String | issueHttpRequest(String methodName, int[] rc, String host, String port, String path) Create an HTTP request line from the following parameters. Open a socket to the specified host and port, and issue the request. Integer portInt = Integer.valueOf(port); Socket s = new Socket(host, portInt); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(s.getOutputStream())); String requestLine = methodName + " /" + path + " HTTP/1.1\r\n"; writer.write(requestLine); writer.write("Host: " + host + ":" + port + "\r\n"); writer.write("User-Agent: systest-client\r\n"); writer.write("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"); ... |
boolean | isTcpPortOpen(int port) is Tcp Port Open return isTcpPortOpen(new InetSocketAddress(InetAddress.getLoopbackAddress(), port), DEFAULT_CONNECT_TIMEOUT_MS); |
Callable | isTcpPortOpenCallable(final int port) is Tcp Port Open Callable return new Callable<Boolean>() { public Boolean call() throws Exception { return isTcpPortOpen(port); }; |
Callable | isTcpPortOpenCallable(final int port) is Tcp Port Open Callable return isTcpPortOpenCallable(port, DEFAULT_CONNECT_TIMEOUT_MS);
|
Class | loadStringSupportedType(String javaType) load String Supported Type if ("java.io.File".equals(javaType)) { return String.class; } else if ("java.net.URL".equals(javaType)) { return String.class; } else if ("java.net.URI".equals(javaType)) { return String.class; return null; ... |
InetSocketAddress | parse(final String desc, final int defaultPort) Parse an address string such as host:port or *:port . String hostStr; String portStr; if (desc.startsWith("[")) { final int hostEnd = desc.indexOf(']'); if (hostEnd < 0) { throw new IllegalArgumentException("invalid IPv6: " + desc); hostStr = desc.substring(1, hostEnd); ... |
List | parse(String specs, int defaultPort) Parses a space and/or comma separated sequence of server specifications of the form hostname or hostname:port. List<InetSocketAddress> result = new ArrayList<InetSocketAddress>(1); if (specs == null) { result.add(new InetSocketAddress("localhost", defaultPort)); } else { String[] specStrings = specs.split("[ ,]+"); for (String specString : specStrings) { int colon = specString.indexOf(':'); if (colon < 0 || colon == specString.length() - 1) { ... |
List | parseCommaDelimitedHosts2(String hosts, int port_range) Input is "daddy[8880],sindhu[8880],camille[5555]. StringTokenizer tok = new StringTokenizer(hosts, ","); String t; InetSocketAddress addr; Set<InetSocketAddress> retval = new HashSet<InetSocketAddress>(); while (tok.hasMoreTokens()) { t = tok.nextToken().trim(); String host = t.substring(0, t.indexOf('[')); host = host.trim(); ... |
InetSocketAddress | parseHostPort(String s) parse Host Port String[] split = s.split(":", 2); int port = DEFAULT_PORT; if (split.length == 2) { try { port = Integer.parseInt(split[1]); } catch (NumberFormatException ex) { return new InetSocketAddress(split[0], port); |
InetSocketAddress | parsePort(String s) Parse the PORT command String[] toks = Pattern.compile(",").split(s); byte[] bAddr = new byte[4]; for (int j = 0; j < 4; j++) { bAddr[j] = new Integer(toks[j]).byteValue(); InetAddress addr = null; try { addr = InetAddress.getByAddress(bAddr); ... |