我正在做一個java的whois在android上訓練流和tcp連接。whois在java爲Android
但我有一個問題。我有一段時間前寫過的php腳本,我正在嘗試在java中做同樣的事情。
這是我的Java代碼:
public String consultawhois(String domain,String tld)
{
String domquest = domain + "." + tld;
String resultado = "";
Socket theSocket;
String hostname = "whois.internic.net";
int port = 43;
try {
theSocket = new Socket(hostname, port, true);
Writer out = new OutputStreamWriter(theSocket.getOutputStream());
out.write(domquest + "\r\n");
out.flush();
DataInputStream theWhoisStream;
theWhoisStream = new DataInputStream(theSocket.getInputStream());
String s;
while ((s = theWhoisStream.readLine()) != null) {
resultado = resultado + s + "\n";
}
}
catch (IOException e) {
}
return resultado;
}
服務器的答案是不正確的,我認爲這個問題是我送一個壞的查詢。我發送的查詢是「dominio.com \ r \ n」,在我的php whois代碼中,它完美地工作。
我已經找到了很多不同的腳本來使這在java中,查詢結構是相同的! – user1185430 2012-02-02 15:36:08
如果我嘗試google.com,它說GOOGLE.COM沒有匹配.... – user1185430 2012-02-02 15:54:39
我認爲有*多個*匹配。不是「不匹配」。查詢= google.com,它會給你正確的答案。 – 2012-02-02 16:01:22