标签:server new length 客户端 client == span 启动 socket
1.创建服务器,并启动(用ServerSocket类)
ServerSocket server = new SocketServer(8888);
//接受客户端
Socket client = server.accept();
//接受客户端的请求信息
//先建立输入流
BufferedReader dos =new BufferedReader(new InputStreamReader(client.getInputStream()));
//开始读取,接受信息
String msg =null;
StringBuilder sb = new StringBuilder();
while((msg=dos.readLine()).length>0){
sb.append(msg);
sb.append("\r\n");
if(msg==null){
break;
}
//得出的信息,去除空格,减少储存空间。
String infomsg= sb.toString().trim
}
标签:server new length 客户端 client == span 启动 socket
原文地址:http://www.cnblogs.com/LeonLau1/p/7538803.html