首页 > 代码库 > httpServer V1

httpServer V1

 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 stub13         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+"\r\n");  // 25             26         }27         28         System.out.println(sbf.toString());29         }30         31         32 33     }34 35 }

 

httpServer V1