码迷,mamicode.com
首页 > Web开发 > 详细

httpServer V1

时间:2014-11-08 22:06:43      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   ar   os   java   sp   

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

 

httpServer V1

标签:style   blog   http   io   color   ar   os   java   sp   

原文地址:http://www.cnblogs.com/hansongjiang/p/4084052.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!