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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Boost Asio总结(15)class basic_stream_socket

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

1.

. 多種構造函數重載
一個參數:I/O服務
兩個參數:1.I/O服務和協議;2.I/O服務和socket端點

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

. 異步讀寫函數

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;//構造函數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;}... }

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。