Created
March 11, 2014 22:21
-
-
Save Yengas/9496344 to your computer and use it in GitHub Desktop.
Java WHOIS protocol with TCP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.io.OutputStream; | |
import java.net.InetAddress; | |
import java.net.Socket; | |
public class Whois { | |
public static void main(String[] args) throws Exception { | |
String domain = args.length > 0 ? args[0] : "domain"; | |
InetAddress address = InetAddress.getByName("whois.internic.net"); | |
Socket socket = new Socket(address, 43); | |
BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream())); | |
socket.getOutputStream().write((domain + "\r\n").getBytes()); | |
String cevap = null; | |
while((cevap = br.readLine()) != null){ System.out.println(cevap); } | |
socket.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment