• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ BOOST_ASIO_MOVE_ARG函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中BOOST_ASIO_MOVE_ARG函数的典型用法代码示例。如果您正苦于以下问题:C++ BOOST_ASIO_MOVE_ARG函数的具体用法?C++ BOOST_ASIO_MOVE_ARG怎么用?C++ BOOST_ASIO_MOVE_ARG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了BOOST_ASIO_MOVE_ARG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: basic_yield_context

namespace asio {

template< typename Handler >
class basic_yield_context {
public:
  basic_yield_context(
          boost::fibers::context * ctx,
          Handler& handler) :
      ctx_( ctx),
      handler_( handler),
      ec_( 0) {
  }

  basic_yield_context operator[]( boost::system::error_code & ec) {
      basic_yield_context tmp( * this);
      tmp.ec_ = & ec;
      return tmp;
  }

private:
  boost::fibers::context        *   ctx_;
  Handler                       &   handler_;
  boost::system::error_code     *   ec_;
};

typedef basic_yield_context<
  boost::asio::detail::wrapped_handler<
    boost::asio::io_service::strand, void(*)(),
    boost::asio::detail::is_continuation_if_running> > yield_context;

template< typename Handler, typename Function >
void spawn( boost::asio::io_service & io_service,
        BOOST_ASIO_MOVE_ARG( Handler) handler,
        BOOST_ASIO_MOVE_ARG( Function) function);

template< typename Handler, typename Function >
void spawn( boost::asio::io_service & io_service,
        basic_yield_context< Handler > ctx,
        BOOST_ASIO_MOVE_ARG( Function) function);

template< typename Function >
void spawn( boost::asio::io_service::strand strand,
        BOOST_ASIO_MOVE_ARG( Function) function);

template< typename Function >
void spawn( boost::asio::io_service & io_service,
        BOOST_ASIO_MOVE_ARG( Function) function);

}}}
开发者ID:flavioroth,项目名称:boost-fiber,代码行数:49,代码来源:spawn.hpp


示例2: async_accept

    async_accept(basic_socket<Protocol1, SocketService>& peer,
                 BOOST_ASIO_MOVE_ARG(AcceptHandler) handler,
                 typename enable_if<is_convertible<Protocol, Protocol1>::value>::type* = 0)
    {
        // If you get an error on the following line it means that your handler does
        // not meet the documented type requirements for a AcceptHandler.
        BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check;

        return this->get_service().async_accept(this->get_implementation(),
                                                peer, static_cast<endpoint_type*>(0),
                                                BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
    }
开发者ID:cboulay,项目名称:labstreaminglayer,代码行数:12,代码来源:basic_socket_acceptor.hpp


示例3: async_accept

      async_accept(implementation_type& impl,
                   basic_socket<Protocol1, SocketService>& peer,
                   endpoint_type* peer_endpoint,
                   BOOST_ASIO_MOVE_ARG(AcceptHandler) handler,
                   typename enable_if<
                       is_convertible<Protocol, Protocol1>::value>::type* = 0) {
    boost::asio::detail::async_result_init<AcceptHandler,
                                           void(boost::system::error_code)>
                                           init(BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
    
    {
      boost::recursive_mutex::scoped_lock lock_state(impl->state_mutex);
      if (impl->closed) {
        auto handler_to_post = [init]() mutable {
          init.handler(
            boost::system::error_code(ssf::error::not_connected,
            ssf::error::get_ssf_category()));
        };
        this->get_io_service().post(handler_to_post);

        return init.result.get();
      }
    }

    boost::system::error_code ec;

    auto fiber_impl = peer.native_handle();
    fiber_impl->p_fib_demux = impl->p_fib_demux;
    fiber_impl->id.set_local_port(impl->id.local_port());

    BOOST_LOG_TRIVIAL(debug) << "fiber acceptor: local port set " << impl->id.local_port();

    typedef detail::pending_accept_operation<
        AcceptHandler, typename Protocol::socket_type> op;
    typename op::ptr p = {
        boost::asio::detail::addressof(init.handler),
        boost_asio_handler_alloc_helpers::allocate(sizeof(op), init.handler),
        0};

    p.p = new (p.v)
        op(peer.native_handle(), &(peer.native_handle()->id), init.handler);
    {
      boost::recursive_mutex::scoped_lock lock(impl->accept_op_queue_mutex);
      impl->accept_op_queue.push(p.p);
    }
    p.v = p.p = 0;
    impl->a_queues_handler();

    return init.result.get();
  }
开发者ID:chrisaljoudi,项目名称:ssf,代码行数:50,代码来源:fiber_acceptor_service.hpp


示例4: async_receive_header

	// @end code
	// @begin example
	//  void receive_header_handler(const boost::system::error_code& ec)
	//  {
	//    if (!ec)
	//    {
	//      // 请求成功!
	//    }
	//  }
	//  ...
	//  avhttp::http_stream h(io_service);
	//  ...
	//  h.async_recvive_header(boost::bind(&receive_header_handler, boost::asio::placeholders::error));
	// @end example
	template <typename Handler>
	void async_receive_header(BOOST_ASIO_MOVE_ARG(Handler) handler);

	///清除读写缓冲区数据.
	// @备注: 非线程安全! 不应在正在进行读写操作时进行该操作!
	AVHTTP_DECL void clear();

	///关闭http_stream.
	// @失败抛出asio::system_error异常.
	// @备注: 停止所有正在进行的读写操作, 正在进行的异步调用将回调
	// boost::asio::error::operation_aborted错误.
	AVHTTP_DECL void close();

	///关闭http_stream.
	// @param ec保存失败信息.
	// @备注: 停止所有正在进行的读写操作, 正在进行的异步调用将回调
	// boost::asio::error::operation_aborted错误.
开发者ID:hicdre,项目名称:avhttp,代码行数:31,代码来源:http_stream.hpp


示例5: wait

  {
    return service_impl_.cancel(impl, ec);
  }

  // Wait for a signaled state.
  void wait(implementation_type& impl, boost::system::error_code& ec)
  {
    service_impl_.wait(impl, ec);
  }

  /// Start an asynchronous wait.
  template <typename WaitHandler>
  BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
      void (boost::system::error_code))
  async_wait(implementation_type& impl,
      BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
  {
    boost::asio::detail::async_result_init<
      WaitHandler, void (boost::system::error_code)> init(
        BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));

    service_impl_.async_wait(impl, init.handler);

    return init.result.get();
  }

private:
  // Destroy all user-defined handler objects owned by the service.
  void shutdown_service()
  {
    service_impl_.shutdown_service();
开发者ID:Sandern,项目名称:py-source-sdk-2013,代码行数:31,代码来源:object_handle_service.hpp


示例6: BOOST_ASIO_INITFN_RESULT_TYPE

 * not, the handler will not be invoked from within this function. Invocation of
 * the handler will be performed in a manner equivalent to using
 * boost::asio::io_service::post().
 *
 * @note This overload is equivalent to calling:
 * @code boost::asio::async_read_at(
 *     d, 42, b,
 *     boost::asio::transfer_all(),
 *     handler); @endcode
 */
template <typename AsyncRandomAccessReadDevice, typename Allocator,
    typename ReadHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
    void (boost::system::error_code, std::size_t))
async_read_at(AsyncRandomAccessReadDevice& d, uint64_t offset,
    basic_streambuf<Allocator>& b, BOOST_ASIO_MOVE_ARG(ReadHandler) handler);

/// Start an asynchronous operation to read a certain amount of data at the
/// specified offset.
/**
 * This function is used to asynchronously read a certain number of bytes of
 * data from a random access device at the specified offset. The function call
 * always returns immediately. The asynchronous operation will continue until
 * one of the following conditions is true:
 *
 * @li The completion_condition function object returns 0.
 *
 * This operation is implemented in terms of zero or more calls to the device's
 * async_read_some_at function.
 *
 * @param d The device from which the data is to be read. The type must support
开发者ID:3Jade,项目名称:Sprawl,代码行数:31,代码来源:read_at.hpp


示例7: BOOST_ASIO_INITFN_RESULT_TYPE

   *
   * @param type The type of handshaking to be performed, i.e. as a client or as
   * a server.
   *
   * @param handler The handler to be called when the handshake operation
   * completes. Copies will be made of the handler as required. The equivalent
   * function signature of the handler must be:
   * @code void handler(
   *   const boost::system::error_code& error // Result of operation.
   * ); @endcode
   */
  template <typename HandshakeHandler>
  BOOST_ASIO_INITFN_RESULT_TYPE(HandshakeHandler,
      void (boost::system::error_code))
  async_handshake(handshake_type type,
      BOOST_ASIO_MOVE_ARG(HandshakeHandler) handler)
  {
    // If you get an error on the following line it means that your handler does
    // not meet the documented type requirements for a HandshakeHandler.
    BOOST_ASIO_HANDSHAKE_HANDLER_CHECK(HandshakeHandler, handler) type_check;

    boost::asio::detail::async_result_init<
      HandshakeHandler, void (boost::system::error_code)> init(
        BOOST_ASIO_MOVE_CAST(HandshakeHandler)(handler));

    detail::async_io(next_layer_, core_,
        detail::handshake_op(type), init.handler);

    return init.result.get();
  }
开发者ID:BranchMetrics,项目名称:react-native-branch-deep-linking,代码行数:30,代码来源:stream.hpp


示例8: spawn

/// completes.
/**
 * This function is used to launch a new coroutine.
 *
 * @param handler A handler to be called when the coroutine exits. More
 * importantly, the handler provides an execution context (via the the handler
 * invocation hook) for the coroutine. The handler must have the signature:
 * @code void handler(); @endcode
 *
 * @param function The coroutine function. The function must have the signature:
 * @code void function(basic_yield_context<Handler> yield); @endcode
 *
 * @param attributes Boost.Coroutine attributes used to customise the coroutine.
 */
template <typename Handler, typename Function>
void spawn(BOOST_ASIO_MOVE_ARG(Handler) handler,
           BOOST_ASIO_MOVE_ARG(Function) function,
           const pdalboost::coroutines::attributes& attributes
           = pdalboost::coroutines::attributes());

/// Start a new stackful coroutine, inheriting the execution context of another.
/**
 * This function is used to launch a new coroutine.
 *
 * @param ctx Identifies the current coroutine as a parent of the new
 * coroutine. This specifies that the new coroutine should inherit the
 * execution context of the parent. For example, if the parent coroutine is
 * executing in a particular strand, then the new coroutine will execute in the
 * same strand.
 *
 * @param function The coroutine function. The function must have the signature:
开发者ID:GeospatialDaryl,项目名称:PDAL,代码行数:31,代码来源:spawn.hpp


示例9: BOOST_ASIO_INITFN_RESULT_TYPE

 * @li Constructs an object @c result of type <tt>async_result<Handler></tt>,
 * initializing the object as <tt>result(handler)</tt>.
 *
 * @li Obtains the handler's associated executor object @c ex by performing
 * <tt>get_associated_executor(handler)</tt>.
 *
 * @li Obtains the handler's associated allocator object @c alloc by performing
 * <tt>get_associated_allocator(handler)</tt>.
 *
 * @li Performs <tt>ex.dispatch(std::move(handler), alloc)</tt>.
 *
 * @li Returns <tt>result.get()</tt>.
 */
template <typename CompletionToken>
BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
    BOOST_ASIO_MOVE_ARG(CompletionToken) token);

/// Submits a completion token or function object for execution.
/**
 * This function submits an object for execution using the specified executor.
 * The function object is queued for execution, and is never called from the
 * current thread prior to returning from <tt>dispatch()</tt>.
 *
 * This function has the following effects:
 *
 * @li Constructs a function object handler of type @c Handler, initialized
 * with <tt>handler(forward<CompletionToken>(token))</tt>.
 *
 * @li Constructs an object @c result of type <tt>async_result<Handler></tt>,
 * initializing the object as <tt>result(handler)</tt>.
 *
开发者ID:ASMlover,项目名称:study,代码行数:31,代码来源:dispatch.hpp


示例10: operator

  template <typename CompletionHandler>
  void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler) const
  {
    typedef typename decay<CompletionHandler>::type DecayedHandler;

    typename associated_executor<DecayedHandler>::type ex(
        (get_associated_executor)(handler));

    typename associated_allocator<DecayedHandler>::type alloc(
        (get_associated_allocator)(handler));

    ex.dispatch(BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler), alloc);
  }

  template <typename CompletionHandler, typename Executor>
  void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
      BOOST_ASIO_MOVE_ARG(Executor) ex) const
  {
    typedef typename decay<CompletionHandler>::type DecayedHandler;

    typename associated_allocator<DecayedHandler>::type alloc(
        (get_associated_allocator)(handler));

    ex.dispatch(detail::work_dispatcher<DecayedHandler>(
          BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)), alloc);
  }
};

} // namespace detail

template <typename CompletionToken>
开发者ID:boostorg,项目名称:asio,代码行数:31,代码来源:dispatch.hpp


示例11: BOOST_ASIO_MOVE_ARG

#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/system_context.hpp>

#include <boost/asio/detail/push_options.hpp>

namespace boost {
namespace asio {

inline system_context& system_executor::context() const BOOST_ASIO_NOEXCEPT
{
  return detail::global<system_context>();
}

template <typename Function, typename Allocator>
void system_executor::dispatch(
    BOOST_ASIO_MOVE_ARG(Function) f, const Allocator&) const
{
  typename decay<Function>::type tmp(BOOST_ASIO_MOVE_CAST(Function)(f));
  boost_asio_handler_invoke_helpers::invoke(tmp, tmp);
}

template <typename Function, typename Allocator>
void system_executor::post(
    BOOST_ASIO_MOVE_ARG(Function) f, const Allocator& a) const
{
  typedef typename decay<Function>::type function_type;

  system_context& ctx = detail::global<system_context>();

  // Allocate and construct an operation to wrap the function.
  typedef detail::executor_op<function_type, Allocator> op;
开发者ID:PopcornTimeTV,项目名称:PopcornTorrent,代码行数:31,代码来源:system_executor.hpp


示例12: BOOST_ASIO_DEFINE_HANDLER_ALLOCATOR_PTR

#include <boost/asio/detail/push_options.hpp>

namespace boost {
namespace asio {
namespace detail {

template <typename Handler, typename Alloc,
    typename Operation = scheduler_operation>
class executor_op : public Operation
{
public:
  BOOST_ASIO_DEFINE_HANDLER_ALLOCATOR_PTR(executor_op);

  template <typename H>
  executor_op(BOOST_ASIO_MOVE_ARG(H) h, const Alloc& allocator)
    : Operation(&executor_op::do_complete),
      handler_(BOOST_ASIO_MOVE_CAST(H)(h)),
      allocator_(allocator)
  {
  }

  static void do_complete(void* owner, Operation* base,
      const boost::system::error_code& /*ec*/,
      std::size_t /*bytes_transferred*/)
  {
    // Take ownership of the handler object.
    executor_op* o(static_cast<executor_op*>(base));
    Alloc allocator(o->allocator_);
    ptr p = { detail::addressof(allocator), o, o };
开发者ID:PopcornTimeTV,项目名称:PopcornTorrent,代码行数:29,代码来源:executor_op.hpp


示例13: BOOST_ASIO_INITFN_RESULT_TYPE

   *   }
   * }
   *
   * ...
   *
   * boost::asio::posix::stream_descriptor descriptor(io_context);
   * ...
   * descriptor.async_wait(
   *     boost::asio::posix::stream_descriptor::wait_read,
   *     wait_handler);
   * @endcode
   */
  template <typename WaitHandler>
  BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
      void (boost::system::error_code))
  async_wait(wait_type w, BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
  {
    // If you get an error on the following line it means that your handler does
    // not meet the documented type requirements for a WaitHandler.
    BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;

    async_completion<WaitHandler,
      void (boost::system::error_code)> init(handler);

    this->get_service().async_wait(
        this->get_implementation(), w, init.completion_handler);

    return init.result.get();
  }

protected:
开发者ID:CustomOrthopaedics,项目名称:OTS-Boost,代码行数:31,代码来源:descriptor.hpp


示例14: async_accept

   *   {
   *     // Accept succeeded.
   *   }
   * }
   *
   * ...
   *
   * boost::asio::ip::tcp::acceptor acceptor(io_service);
   * ...
   * boost::asio::ip::tcp::socket socket(io_service);
   * acceptor.async_accept(socket, accept_handler);
   * @endcode
   */
  template <typename SocketService, typename AcceptHandler>
  void async_accept(basic_socket<protocol_type, SocketService>& peer,
      BOOST_ASIO_MOVE_ARG(AcceptHandler) handler)
  {
    // If you get an error on the following line it means that your handler does
    // not meet the documented type requirements for a AcceptHandler.
    BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check;

    this->get_service().async_accept(this->get_implementation(),
        peer, 0, BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
  }

  /// Accept a new connection and obtain the endpoint of the peer
  /**
   * This function is used to accept a new connection from a peer into the
   * given socket, and additionally provide the endpoint of the remote peer.
   * The function call will block until a new connection has been accepted
   * successfully or an error occurs.
开发者ID:AndresGalaviz,项目名称:NAO,代码行数:31,代码来源:basic_socket_acceptor.hpp


示例15: basic_registration

  : public basic_io_object<RegistrationService>
{
public:

  explicit basic_registration(io_service& io,
      std::string name)
			// eventually, this will have to be wstring or  
			// something - name is UTF-8   [dns-sd.h : 883]
    : basic_io_object<RegistrationService>(io)
  {
  }

  /// Commit a registration
  template <typename CommitHandler>
  inline BOOST_ASIO_INITFN_RESULT_TYPE(CommitHandler,
      void(boost::system::error_code))
  async_commit(BOOST_ASIO_MOVE_ARG(CommitHandler) handler)
  {
    return this->get_service().async_commit(
      this->get_implementation(),
      BOOST_ASIO_MOVE_CAST(CommitHandler)(handler));
  }
};

typedef basic_registration<registration_service> registration;

} // namespace dnssd
} // namespace ip
} // namespace asio
} // namespace boost
开发者ID:bkietz,项目名称:boost-asio-dnssd,代码行数:30,代码来源:registration.hpp


示例16: message

    if(timeout == Duration::zero()) {
      //TODO this can return false if it failed
      impl.send(m);
      return message();
    } else {
      return impl.send_with_reply_and_block(m,
        chrono::milliseconds(timeout).count());
    }
  }

  template<typename MessageHandler>
  inline BOOST_ASIO_INITFN_RESULT_TYPE(MessageHandler,
      void(boost::system::error_code, message))
  async_send(implementation_type& impl,
      message& m,
      BOOST_ASIO_MOVE_ARG(MessageHandler) handler)
  {
    // begin asynchronous operation
    impl.start(this->get_io_service());

    boost::asio::detail::async_result_init<
      MessageHandler, void(boost::system::error_code, message)> init(
        BOOST_ASIO_MOVE_CAST(MessageHandler)(handler));

    detail::async_send_op<
      BOOST_ASIO_HANDLER_TYPE(MessageHandler,
        void(boost::system::error_code, message))>(
          this->get_io_service(),
            BOOST_ASIO_MOVE_CAST(MessageHandler)(init.handler)) (impl, m);

    return init.result.get();
开发者ID:10orochi01,项目名称:boost-dbus,代码行数:31,代码来源:connection_service.hpp


示例17: flush

    return stream_impl_.next_layer().flush();
  }

  /// Flush all data from the buffer to the next layer. Returns the number of
  /// bytes written to the next layer on the last write operation, or 0 if an
  /// error occurred.
  std::size_t flush(boost::system::error_code& ec)
  {
    return stream_impl_.next_layer().flush(ec);
  }

  /// Start an asynchronous flush.
  template <typename WriteHandler>
  BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
      void (boost::system::error_code, std::size_t))
  async_flush(BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
  {
    return stream_impl_.next_layer().async_flush(
        BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
  }

  /// Write the given data to the stream. Returns the number of bytes written.
  /// Throws an exception on failure.
  template <typename ConstBufferSequence>
  std::size_t write_some(const ConstBufferSequence& buffers)
  {
    return stream_impl_.write_some(buffers);
  }

  /// Write the given data to the stream. Returns the number of bytes written,
  /// or 0 if an error occurred.
开发者ID:Bugaa92,项目名称:ProiectAPP,代码行数:31,代码来源:buffered_stream.hpp


示例18: request

    virtual ~basic_coproto_handle()
    {
        //std::cout << "coproto_handle destructor" << std::endl;
    }

    std::string request() const
    {
        return this->service.request(this->implementation);
    }

    void request(const std::string& req)
    {
        this->service.request(this->implementation, req);
    }

    template <typename DoHandler>
    BOOST_ASIO_INITFN_RESULT_TYPE(DoHandler,
        void (boost::system::error_code, std::string))
    async_do(BOOST_ASIO_MOVE_ARG(DoHandler) handler)
    {
        // HANDLER_CHECK macro needs to be created and called

        return this->service.async_do(this->implementation,
            BOOST_ASIO_MOVE_CAST(DoHandler)(handler));
    }
};

typedef basic_coproto_handle<std::string, QueueManager > coproto_handle;

#endif /* COPROTO_HANDLE_HPP_ */
开发者ID:ryanpartridge,项目名称:scratchpad,代码行数:30,代码来源:coproto_handle.hpp


示例19: async_wait

   * @li The timer was cancelled, in which case the handler is passed the error
   * code boost::asio::error::operation_aborted.
   *
   * @param handler The handler to be called when the timer expires. Copies
   * will be made of the handler as required. The function signature of the
   * handler must be:
   * @code void handler(
   *   const boost::system::error_code& error // Result of operation.
   * ); @endcode
   * Regardless of whether the asynchronous operation completes immediately or
   * not, the handler will not be invoked from within this function. Invocation
   * of the handler will be performed in a manner equivalent to using
   * boost::asio::io_service::post().
   */
  template <typename WaitHandler>
  void async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
  {
    // If you get an error on the following line it means that your handler does
    // not meet the documented type requirements for a WaitHandler.
    BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;

    this->service.async_wait(this->implementation,
        BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
  }
};

} // namespace asio
} // namespace boost

#include <boost/asio/detail/pop_options.hpp>
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:30,代码来源:basic_deadline_timer.hpp


示例20: connect


//.........这里部分代码省略.........
 * @par Example
 * @code tcp::resolver r(io_service);
 * tcp::resolver::query q("host", "service");
 * tcp::socket s(io_service);
 *
 * // ...
 *
 * r.async_resolve(q, resolve_handler);
 *
 * // ...
 *
 * void resolve_handler(
 *     const boost::system::error_code& ec,
 *     tcp::resolver::iterator i)
 * {
 *   if (!ec)
 *   {
 *     boost::asio::async_connect(s, i, connect_handler);
 *   }
 * }
 *
 * // ...
 *
 * void connect_handler(
 *     const boost::system::error_code& ec,
 *     tcp::resolver::iterator i)
 * {
 *   // ...
 * } @endcode
 */
template <typename Protocol, typename SocketService,
    typename Iterator, typename ComposedConnectHandler>
void async_connect(basic_socket<Protocol, SocketService>& s,
    Iterator begin, BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler);

/// Asynchronously establishes a socket connection by trying each endpoint in a
/// sequence.
/**
 * This function attempts to connect a socket to one of a sequence of
 * endpoints. It does this by repeated calls to the socket's @c async_connect
 * member function, once for each endpoint in the sequence, until a connection
 * is successfully established.
 *
 * @param s The socket to be connected. If the socket is already open, it will
 * be closed.
 *
 * @param begin An iterator pointing to the start of a sequence of endpoints.
 *
 * @param end An iterator pointing to the end of a sequence of endpoints.
 *
 * @param handler The handler to be called when the connect operation
 * completes. Copies will be made of the handler as required. The function
 * signature of the handler must be:
 * @code void handler(
 *   // Result of operation. if the sequence is empty, set to
 *   // boost::asio::error::not_found. Otherwise, contains the
 *   // error from the last connection attempt.
 *   const boost::system::error_code& error,
 *
 *   // On success, an iterator denoting the successfully
 *   // connected endpoint. Otherwise, the end iterator.
 *   Iterator iterator
 * ); @endcode
 * Regardless of whether the asynchronous operation completes immediately or
 * not, the handler will not be invoked from within this function. Invocation
 * of the handler will be performed in a manner equivalent to using
开发者ID:13609594236,项目名称:ph-open,代码行数:67,代码来源:connect.hpp



注:本文中的BOOST_ASIO_MOVE_ARG函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ BOOST_ASIO_TEST_CASE函数代码示例发布时间:2022-05-30
下一篇:
C++ BOOST_ASIO_HANDLER_INVOCATION_BEGIN函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap