简体   繁体   中英

Connection Refused?

I am getting the following exception in my code: 在此处输入图片说明

I cant understand the reason for this exception...

here is my code: {

import java.net.*;
 import java.io.*;
 class whois {
  public static void main(String args[])throws Exception {
   int c;
   Socket s=new Socket("internic.net",43);
   InputStream in=s.getInputStream();
   OutputStream out=s.getOutputStream();
   String str=(args.length==0 ? "webopedia.com" : args[0])+"\n";
   byte buf[]=str.getBytes();
   out.write(buf);
   while((c=in.read())!=-1) {
    System.out.print((char)c);
   }
    s.close();
   }
  }
 }

please tell the reason for this exception.

In brief: you can't connect with internic.net on port 43 from your current client. Either the server port ist not available, your firewall blocks traffic or your client can't resolve the symbolic name of the server.

I did a bit of digging around. Port 43 is the WHOIS service, and it seems that you should be using "whois.internic.net" as the hostname for the Internic instance of the WHOIS service.


I'm currently getting "No route to host" for whois.internic.net ...

My conclusion is that the host and/or services at whois.internic.net are unreliable at the moment. I suggest that you use the search form at "http://internic.net/whois.html" instead.


The search form above gives no information for "www.webopedia.com" ... because it has no information about that domain! But it DOES have information about "webopedia.com". That makes sense to me:

  • "webopedia.com" is the primary domain name that is registered with some domain registrar and served by the ".com" DNS servers. It has WHOIS information.

  • "www.webopedia.com" is a subdomain whose DNS information is served by the people who run "webopedia.com"; see above.

This is all confirmed by looking at the DNS records for the two names. Use dig or the equivalent Windows tool to look at the DNS records.

In short, your program is telling the truth ... when it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM