?? usesocketinfo.java
字號:
import java.net.*;
import java.io.*;
public class useSocketInfo
{
public static void main(String[] args) {
for (int i = 0; i < args.length; i++) {
try {
// 建立Socket對象
Socket theSocket = new Socket(args[i], 80);
// 輸入端口信息
System.out.println("連接到 " + theSocket.getInetAddress()
+ " on port " + theSocket.getPort() + " from port "
+ theSocket.getLocalPort() + " of " + theSocket.getLocalAddress());
} // end try
catch (UnknownHostException e) {
System.err.println("不能找到 " + args[i]);
}
catch (SocketException e) {
System.err.println("Could not connect to " + args[i]);
}
catch (IOException e) {
System.err.println(e);
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -