标签:io ar os sp java on art bs ad
package Chapter3;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
public class EchoServer {
private ServerSocket server;
private int port = 8000;
private Socket socket;
public EchoServer() {
try {
server = new ServerSocket(port);
} catch (IOException e) {
System.out.println("未启动ServerSocket");
}
}
public void service() {
while(true){
try {
System.out.println("EchoServer等待客户端连接");
socket=server.accept();
Thread workThread=new Thread(new Handler(socket));
workThread.start();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
new EchoServer().service();
}
}
标签:io ar os sp java on art bs ad
原文地址:http://www.cnblogs.com/stay-sober/p/4158800.html