不知道哪里错了,没达到毕姥爷视频中,用浏览器访问得到回馈信息的效果- 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();
- }
- }
复制代码 |