zoukankan      html  css  js  c++  java
  • CS

    1、把服务器的数据写到客户端   用 socket.getOutputStream()。

    开启telnet作为客户端。

    public class ChatService {
        public static void main(String[] args) throws Exception {
            new ChatService().start();
        }
    
        private void start() throws Exception {
            ServerSocket server=new ServerSocket(8090);
            while(true){
            Socket socket=server.accept();
            OutputStream out=socket.getOutputStream();
            String s="hello client";
            byte [] data=s.getBytes();
            out.write(data);
            out.flush();
            out.close();
            }
        }
    
    }

    2、怎样将客户端的数据传到服务器:

    用socket.getInputSream();

  • 相关阅读:
    css3 3d 转换
    css3 动画序列
    css3 动画
    2d 转换之缩放
    2d 转换中心点
    css3 书写 动画三角形
    2d 旋转
    2D转换
    伪元素 字体图标
    风陵01
  • 原文地址:https://www.cnblogs.com/wintersong/p/4754162.html
Copyright © 2011-2022 走看看