?? scoket2.java
字號:
package scoket;
/*第2題*/
import java.awt.*;
import java.io.*;
import java.net.*;
public class Scoket2 {
public static void main(String[] args) {
String host="localhost";
int port=4050;
try{
while(true){
//因為服務器每次accept才new Date,所以客戶端要while(true) new Socket
System.out.println("Get time from a TCP server on"+host+":"+port);
Socket socket=new Socket(host,port);
BufferedReader in=new BufferedReader(
new InputStreamReader(socket.getInputStream()));
String s=in.readLine();
System.out.println(s);
Thread.sleep(1000);
}
}
catch(IOException e){
System.err.println(e);
}
catch(InterruptedException e){
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -