Close
jGuru Forums
Posted By: Wayne_Wylupski Posted On: Thursday, December 13, 2001 02:39 PM
Is there a "whois" implementation in Java available? It doesn't seem to be part of the core networking libraries.
I would prefer one that allows the developer to pull out specific data, such as Primary and Secondary name servers, Administrative Contact, etc.
Re: whois class?
Posted By: Anonymous Posted On: Thursday, January 7, 2010 07:31 AM
Posted By: Anthony_Eden Posted On: Friday, January 25, 2002 09:03 AM
One more thing: accessing WHOIS information using an automated process is prohibited by most Registrars. Finally some registrars (Network Solutions for example) actually block access to their WHOIS server after a certain number of requests from a particular IP address. Just something to consider.
Posted By: Luigi_Viggiano Posted On: Tuesday, January 1, 2002 04:08 PM
import java.net.*;import java.io.*;public class Whois { static final int WHOIS_PORT = 43; static final String WHOIS_SERVER_NAME = "whois.internic.net"; static final String QUERY = "jguru.com"; public static void main(String[] args) { try { byte[] queryBytes = QUERY.getBytes(); InetAddress whoisServer = InetAddress.getByName(WHOIS_SERVER_NAME); Socket whoisSocket = new Socket(whoisServer, WHOIS_PORT); InputStream reciever = whoisSocket.getInputStream(); OutputStream sender = whoisSocket.getOutputStream(); sender.write(queryBytes); sender.flush(); byte[] b = new byte[1024]; int length = 0; while ((length = reciever.read(b)) != -1) { System.out.write(b, 0, length); } whoisSocket.close(); } catch (UnknownHostException e) { System.out.println("Unknown host: " + WHOIS_SERVER_NAME); } catch (IOException e) { System.out.println("Network error: " + e.getMessage()); } }}
Posted By: Dermot_Hennessy Posted On: Thursday, December 13, 2001 03:12 PM
Dermot