Home  >  Q&A  >  body text

c++ - 客户端与服务器交互使用什么样的架构较好?

客户端和服务器端的交互已经定型,采用了如下的方式:

1、客户端向服务器端发送请求,获取到接下来需要读取数据的长度;

2、客户端从服务器端读取第一步获取到长度的数据。

按照以上的逻辑,目前写出的代码可读性不高,看着有些怪异。由于这种通信的方式已经不能改变,是否有合理的架构可以满足以上的交互?

PHPzPHPz2714 days ago555

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-04-17 15:19:09

    asio + coroutine

    Reference: http://think-async.com/Asio/a...

    reply
    0
  • 阿神

    阿神2017-04-17 15:19:09

    Write a bottom layer yourself to encapsulate the protocol, read the content data, and then push or call back to the upper layer.

    reply
    0
  • Cancelreply