1 package cn.edu.sss.httpServer; 2 3 import java.io.BufferedReader; 4 import java.io.IOException; 5 import java.io.InputStreamReader; 6 import java.net.ServerSocket; 7 import java.net.Socket; 8 9 public class HttpServer1 { 10 11 public static void main(String[] args) throws IOException { 12 // TODO Auto-generated method stub 13 14 15 ServerSocket server=new ServerSocket(8088); //在8088端口上监听 16 while(true) 17 { 18 Socket s=server.accept(); 19 StringBuffer sbf=new StringBuffer(); 20 BufferedReader buf=new BufferedReader(new InputStreamReader(s.getInputStream())); 21 String mes=null; 22 while((mes=buf.readLine())!=null) 23 { 24 sbf.append(mes+" "); // 25 26 } 27 28 System.out.println(sbf.toString()); 29 } 30 31 32 33 } 34 35 }