java为什么下面的代码使用电子邮件地址作为主机名?
目前,我正在学习socket,并以创建finger客户端为例。我注意到,在以下代码中,主机名应该是电子邮件地址,而不是域名:
import java.io.*;
import java.net.*;
import java.util.*;
public class Finger {
public static void main(String[] args) {
String user;
String host;
if ((args.length == 1) && (args[0].indexOf("@") > -1)) {
StringTokenizer split = new StringTokenizer(args[0],
"@");
user = split.nextToken();
host = split.nextToken();
} else {
System.out.println("Usage: java Finger user@host");
return;
}
try (Socket digit = new Socket(host, 79);
BufferedReader in = new BufferedReader(
new InputStreamReader(digit.getInputStream()));
) {
digit.setSoTimeout(20000);
PrintStream out = new PrintStream(
digit.getOutputStream());
out.print(user + "\015\012");
boolean eof = false;
while (!eof) {
String line = in.readLine();
if (line != null) {
System.out.println(line);
} else {
eof = true;
}
}
digit.close();
} catch (IOException e) {
System.out.println("IO Error:" + e.getMessage());
}
}
}
它不应该是一个域名吗,因为电子邮件地址用于解析电子邮件服务器而不是手指服务器的IP
共 (0) 个答案