troubleshooting Question

Error Message in my Java Program

Avatar of Billy Ma
Billy MaFlag for Hong Kong asked on
9 Comments1 Solution605 ViewsLast Modified:
I don't know why I get the following error message when I run my Java program. In the Code Snippet, this is the function that I modified yesterday.

Cannot open Connection
The driver was unable to create a connection due to an inability to establish th
e client portion of a socket.

This is usually caused by a limit on the number of sockets imposed by the operat
ing system. This limit is usually configurable.

For Unix-based platforms, see the manual page for the 'ulimit' command. Kernel o
r system reconfiguration may also be required.

For Windows-based platforms, see Microsoft Knowledge Base Article 196271 (Q19627
public void fetch_device_data(String device_name){
        String s = null;
		String line = "";
        try {
				FileOutputStream output_file = new FileOutputStream("output.txt");
				FileOutputStream error_file = new FileOutputStream("error.txt");
	            Process p = Runtime.getRuntime().exec("wget -O source_data/" + device_name + ".html http://****:****@"+device_name);
				StreamGobbler outputGobbler = new StreamGobbler(p.getInputStream(), "OUTPUT", output_file);
				StreamGobbler errorGobbler = new StreamGobbler(p.getErrorStream(), "ERROR", error_file);	
				int exitVal = p.waitFor();
	            System.out.println("ExitValue: " + exitVal);
			}catch(Throwable t){
			BufferedReader stdInput = new BufferedReader(new FileReader("source_data/" + device_name + ".html"));
			boolean inside_table_tag = false;
            while ((s = stdInput.readLine()) != null) {
				/* If encounter a table tag */
					if(inside_table_tag == true){
						inside_table_tag = false;
						line = line.replaceAll("<(tr|td)[^>]*>", "<$1>");		//Remove all the attributes in tr and td tags
						line = line.replaceAll("<([/]{0,1}[a-z]*)>[ ]*", "<$1>").trim();
						line = line.replaceAll("</(td|tr)>", "");				//Remove all ending tr and td tags
						line = line.replaceFirst("<td>", "");
						String data[] = line.split("<td>");
					}else if(inside_table_tag == false){
						inside_table_tag = true;
						line = "";
				/* If on a td line */
				if(inside_table_tag && s.contains("<td")){
					line += s + " ";
        catch (IOException e) {
            write_log("exception happened - here's what I know: ");
**** Code Edited for content 5-23-8 MM ****
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros