日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Boost Asio总结(15)class basic_stream_socket

發(fā)布時(shí)間:2025/3/21 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Boost Asio总结(15)class basic_stream_socket 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1.

. 多種構(gòu)造函數(shù)重載
一個(gè)參數(shù):I/O服務(wù)
兩個(gè)參數(shù):1.I/O服務(wù)和協(xié)議;2.I/O服務(wù)和socket端點(diǎn)

. send()/receive()和write_some()/read_some()區(qū)別
  相同:
    功能完全相同;寫數(shù)據(jù)和讀數(shù)據(jù)。
  不同:
    send()/receive()有多種重載

. 異步讀寫函數(shù)

1.1

template <typename Protocol, typename Executor> class basic_stream_socket: public basic_socket<Protocol, Executor> { public:/// The type of the executor associated with the object.typedef Executor executor_type;//構(gòu)造函數(shù)explicit basic_stream_socket(const executor_type& ex): basic_socket<Protocol, Executor>(ex){}template <typename ExecutionContext>explicit basic_stream_socket(ExecutionContext& context,typename enable_if<is_convertible<ExecutionContext&, execution_context&>::value>::type* = 0): basic_socket<Protocol, Executor>(context){}basic_stream_socket(const executor_type& ex, const protocol_type& protocol): basic_socket<Protocol, Executor>(ex, protocol){}template <typename ExecutionContext>basic_stream_socket(ExecutionContext& context, const protocol_type& protocol,typename enable_if<is_convertible<ExecutionContext&, execution_context&>::value>::type* = 0): basic_socket<Protocol, Executor>(context, protocol){}basic_stream_socket(const executor_type& ex, const endpoint_type& endpoint): basic_socket<Protocol, Executor>(ex, endpoint){}// sendtemplate <typename ConstBufferSequence>std::size_t send(const ConstBufferSequence& buffers){boost::system::error_code ec;std::size_t s = this->impl_.get_service().send(this->impl_.get_implementation(), buffers, 0, ec);boost::asio::detail::throw_error(ec, "send");return s;}template <typename ConstBufferSequence>std::size_t send(const ConstBufferSequence& buffers,socket_base::message_flags flags){boost::system::error_code ec;std::size_t s = this->impl_.get_service().send(this->impl_.get_implementation(), buffers, flags, ec);boost::asio::detail::throw_error(ec, "send");return s;}template <typename ConstBufferSequence>std::size_t send(const ConstBufferSequence& buffers,socket_base::message_flags flags, boost::system::error_code& ec){return this->impl_.get_service().send(this->impl_.get_implementation(), buffers, flags, ec);}template <typename ConstBufferSequence, typename WriteHandler>BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,void (boost::system::error_code, std::size_t))async_send(const ConstBufferSequence& buffers,BOOST_ASIO_MOVE_ARG(WriteHandler) handler){return async_initiate<WriteHandler,void (boost::system::error_code, std::size_t)>(initiate_async_send(), handler, this,buffers, socket_base::message_flags(0));}template <typename ConstBufferSequence, typename WriteHandler>BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,void (boost::system::error_code, std::size_t))async_send(const ConstBufferSequence& buffers,socket_base::message_flags flags,BOOST_ASIO_MOVE_ARG(WriteHandler) handler){return async_initiate<WriteHandler,void (boost::system::error_code, std::size_t)>(initiate_async_send(), handler, this, buffers, flags);}template <typename MutableBufferSequence>std::size_t receive(const MutableBufferSequence& buffers){boost::system::error_code ec;std::size_t s = this->impl_.get_service().receive(this->impl_.get_implementation(), buffers, 0, ec);boost::asio::detail::throw_error(ec, "receive");return s;}... }

總結(jié)

以上是生活随笔為你收集整理的Boost Asio总结(15)class basic_stream_socket的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。