//检查命令行参数
if (args.length <1)
{
System.out.println("/nUsage: java whois <command>");
System.out.println("Parameters:");
System.out.println(
"/tcommand = one or more Domain name, or other command.");
System.out.println("Example:");
System.out.println("/tjava whois sohu.com");
System.out.println("/tjava whois help");
System.exit(1); //退出
}
try {
//在TCP服务端口43(十进制)连接SRI-NIC服务主机
theSocket = new Socket(hostname, port, true);
ps = new PrintStream(theSocket.getOutputStream());
//发送用户提供的一个或多个命令
for (int i = 0; i < args.length; i++)
ps.print(args[i] + " ");
//以回车和换行(<CRLF>)结尾
ps.print("/r/n");
//接受相应命令的返回信息
theWhoisStream = new DataInputStream(theSocket.getInputStream());
String s;
while ((s = theWhoisStream.readLine()) != null) {
System.out.println(s);
}