模拟B/S服务器(扩展)

模拟B/S服务器(扩展)

  案例:

   

public class Server {
public static void main(String[] args) throws IOException {
ServerSocket socket = new ServerSocket(8888);
Socket accept = socket.accept();
InputStream is = accept.getInputStream();
int len =0;
byte[] bytes = new byte[1024];
while ((len=is.read(bytes))!=-1){
System.out.println(new String(bytes,0,len));
}
}
}

图解:

   

 

 

posted @ 2022-07-22 13:29  一位程序袁  阅读(27)  评论(0编辑  收藏  举报