FileDocCategorySizeDatePackage
WhoisClient.javaAPI DocExample1281Sat Sep 09 20:34:02 BST 2000None

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)


       

    InetAddress server;
    
    try {
      server = InetAddress.getByName(DEFAULT_HOST);
    }
    catch (UnknownHostException e) {
      System.err.println("Error: Could not locate default host "
       + DEFAULT_HOST);
      System.err.println(
       "Check to make sure you're connected to the Internet and that DNS is funtioning");
      System.err.println("Usage: java WhoisClient host port");         
      return;
    }       
    
    int port = DEFAULT_PORT;

    try {
      Socket theSocket = new Socket(server, 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 e) {
      System.err.println(e);
    }