本帖最后由 hdsjsql 于 2013-5-24 10:01 编辑
为什么运行了以下程序,在浏览器中输入http://127.0.0.1:11000/后,打不开网页- import java.net.*;
- import java.io.*;
- public class ServerDemo
- {
- public static void main(String[] args)throws Exception
- {
- ServerSocket ss=new ServerSocket(11000);
-
- Socket s=ss.accept();
- System.out.println(s.getInetAddress().getHostAddress());
-
- InputStream in=s.getInputStream();
-
- byte[] buf=new byte[1024];
- int len=in.read(buf);
-
- System.out.println(new String(buf,0,len));
-
- PrintWriter out=new PrintWriter(s.getOutputStream(),true);
-
- out.println("客服端你好");
- s.close();
- ss.close();
-
- }
- }
复制代码 |