FileDocCategorySizeDatePackage
WhoisClient.javaAPI DocExample1191Sun Dec 12 10:53:04 GMT 2004None

WhoisClient

public class WhoisClient extends Object

Fields Summary
public static final int
DEFAULT_PORT
public static final String
DEFAULT_HOST
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)


       

    String serverName = System.getProperty("WHOIS_SERVER", DEFAULT_HOST);  
    
    InetAddress server = null;
    try {
      server = InetAddress.getByName(serverName);
    }
    catch (UnknownHostException ex) {
      System.err.println("Error: Could not locate whois server "
       + server);
      System.err.println("Usage: java -DWHOIS_SERVER=hostname WhoisClient name");         
      return;
    }       

    try {
      Socket theSocket = new Socket(server, DEFAULT_PORT);
      Writer out = new OutputStreamWriter(theSocket.getOutputStream(), 
       "8859_1");
      for (int i = 0; i < args.length; i++) out.write(args[i] + " ");
      out.write("\r\n");
      out.flush();
      InputStream raw = theSocket.getInputStream();
      InputStream in  = new BufferedInputStream(theSocket.getInputStream());
      int c;
      while ((c = in.read()) != -1) System.out.write(c);
    }
    catch (IOException ex) {
      System.err.println(ex);
    }