升压ASIO async_read(async_write)包装 [英] Boost asio async_read (async_write) wrapper

查看:248
本文介绍了升压ASIO async_read(async_write)包装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想code的包装在一个boost :: ASIO ::知识产权:: TCP ::插座

I'm trying to code a wrapper over a boost::asio::ip::tcp::socket

类似的东西:

class Socket {
  public:
    void async_read(AsyncReadStream & s,                     
                    const boost::asio::MutableBufferSequence & buffers,   
                    CompletionCondition completion_condition,
                    ReadHandler handler) {};
};

所以,我将能够使用SSL和非SSL流无缝...
唯一的一点是,我不似乎找到每个参数的定义,通过他们来提高:: ASIO :: async_read(命名空间,等...)

So I would be able to use ssl and non-ssl stream seamlessly... The only thing is that, I do not seems to find the definition of each parameters to pass them to boost::asio::async_read (namespaces, etc...)

任何帮助将是AP preciated!谢谢

Any help would be appreciated ! Thanks

推荐答案

您主要的要求似乎是使用SSL和非SSL无缝流。要做到这一点,你可以在暴露你需要使用的功能的方式包装一个不同的流类型。

Your main requirements seems to be "use SSL and non-SSL streams seamlessly." To do that, you can wrap a the various stream types in a way that exposes the functions you need to use.

你如何做到这一点是决定你将如何做内存管理的一部分。 MutableBufferSequence是不是一个类型,它定义了一个要在这种情况下使用的类型一系列要求。

Part of how you do that is deciding how you're going to do memory management. MutableBufferSequence is not a type, it defines a set of requirements for a type to be used on that context.

如果您要使用的方法一个短小人数的你可以使用它们的接口(只要它符合MutableBufferSequence / ConstBufferSequence要求,适当)。这种方法的缺点是,缓冲区管理成为接口的一部分。

If you are going to use one of a smallish number of approaches you can just use them in the interface (as long as it meets the MutableBufferSequence/ConstBufferSequence requirements, appropriate). The downside of this is that buffer management becomes part of the interface.

如果你想保持ASIO缓冲管理的灵活性,那么你可以

If you want to maintain the asio buffer management flexibility then you could


  • 模板上的流类型的code,以实现无缝SSL /非SSL的要求。

  • Template your code on stream type in order to achieve the seamless SSL/non-SSL requirement.

与缓冲区类型模板方法创建的各种流类型的包装。

Create a wrapper for the various stream types with templated methods on buffer type.

(更新响应;!我不应该对这样的问题,当我有不到两分钟响应)

(Updated response; I shouldn't try to respond to a question like this when I have less than two minutes!)

这篇关于升压ASIO async_read(async_write)包装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆