zoukankan      html  css  js  c++  java
  • socket

    server 

    import 'dart:io';
    import 'dart:convert';
    
    main(List<String> arguments) {
      //绑定地址和端口,获取套接字,监听每个连接
      ServerSocket.bind('127.0.0.1', 8089).then((serverSocket) {
        print('开始监听');
        serverSocket.listen((socket) {
          socket.transform(utf8.decoder).listen(print);
    //      socket.remoteAddress
          socket.write('from server');
          print(socket.remoteAddress);
        });
    
      });
    }
    

      

    client

    import 'dart:io';
    
    main(List<String> arguments) {
      //创建一个Socket连接到指定地址与端口
      Socket.connect('127.0.0.1', 8089).then((socket) {
        //输出socket运行时的类型
        print(socket.runtimeType);
        socket.write('Hello, World!');
      });
    }
    

      

  • 相关阅读:
    leetcode931
    leetcode1289
    leetcode1286
    poj Meteor Shower
    noip杂题题解
    noip2007部分题
    NOIP Mayan游戏
    某模拟题题解
    codevs 1423 骑士
    noip 邮票面值设计
  • 原文地址:https://www.cnblogs.com/pythonClub/p/10732507.html
Copyright © 2011-2022 走看看