官網首頁:http://mina.apache.org/html
官網的API:http://mina.apache.org/mina-project/apidocs/index.htmlapache
socket.shutdownoutput():寫完以後的結束標記。api
多人訪問服務器:服務器
ServerSocket ss=new ServerSocket(1007);socket
while(true)線程
{htm
Socket s=ss.accept(); //主線程先等待get
new Thread(new Runnable(){ //當A鏈接進來後,主線程和這個子線程都開啓it
//every client do 讀取客戶端流數據,向客戶端回傳數據cli
}).start();
}
關於鍵盤錄入:
BufferedReader bufr=new BufferedReader(new InputStreamReader(System.in));
PrintWriter out=new PrintWriter(socket.getOutputStream(),true);
String line=null;
while((line=bufr.readLine())!=null)
{
out.println(line);//不用flush(),不用寫結束標記。println就好了
}