zoukankan      html  css  js  c++  java
  • NetworkComms V3 之同步收发数据

     NetworkComms网络通信框架序言
    NetworkComms通信框架,是一款来自英国的c#语言编写的通信框架,历时6年研发,成熟稳定,性能可靠。

    NetworkComms v3的核心功能在一定程度上是以异步的方式进行的。

    NetworkComms提供了相应的功能,使得可以同步请求数据和获得相应的相应,非常的简单。


    try
    {
    //连接信息类
    ConnectionInfo connectionInfo = new ConnectionInfo("127.0.0.1", 10000);

    //获取一个TCP连接
    TCPConnection serverConnection = TCPConnection.GetConnection(connectionInfo);

    //发送一个消息类型是“RequestCustomObject“的,数据类型为int,具体数值为 “1000”的数据给服务器,并获取消息类型为“CustomObjectReply",类型为CustomObject的数据
    CustomObject myCustomObject = serverConnection.SendReceiveObject<CustomObject>("RequestCustomObject", "CustomObjectReply", 1000);


    }
    catch (ExpectedReturnTimeoutException)
    {

    }

    服务器上对应的处理方法:


    NetworkComms.AppendGlobalIncomingPacketHandler<int>("RequestCustomObject", (packetHeader, connection, input) =>
    {
    //创建一个要返回的类型
    CustomObject myCustomObject = new CustomObject();

    //把要返回的类型,发送给客户端
    connection.SendObject("CustomObjectReply", myCustomObject);
    });

    原文:http://www.networkcomms.net/synchronous-send-and-receive/ 

    www.networkcomms.cn整理
    ---------------------
    作者:networkcomms
    来源:CSDN
    原文:https://blog.csdn.net/networkcomms/article/details/44218129
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    逆向工程IL指令集
    关于最近电话面试的体会
    推荐阅读《小就是大》(small is the new big)
    [ZZ]google v. microsoft, and the dev:test ratio debate
    我所用到的Google产品
    [ZZ]7 Useful Tools for Web Development Testing
    拼车新模式
    [ZZ]读《移山之道》后有感
    Google财经香港版上线,香港路演
    [ZZ]从Google到“谷歌”
  • 原文地址:https://www.cnblogs.com/Jeely/p/10972242.html
Copyright © 2011-2022 走看看