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

C++ endpoint_type类代码示例

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

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



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

示例1: bind

		bool bind(endpoint_type& endpoint)
		{
			return socket_ops::bind(
				_socket,
				endpoint.data(),
				endpoint.size());
		}
开发者ID:romsi,项目名称:NetIO,代码行数:7,代码来源:datagram_socket_service.hpp


示例2: listen

 void listen(endpoint_type const & endpoint, boost::system::error_code & ec, bool reuse_addr = true)
 {
     if (endpoint.protocol() == protocol_type::v4())
         v4_type::listen(endpoint, ec, reuse_addr);
     if (endpoint.protocol() == protocol_type::v6())
         v6_type::listen(endpoint, ec, reuse_addr);
 }
开发者ID:mtaneda,项目名称:acqua,代码行数:7,代码来源:internet_server.hpp


示例3: connect

 // Connect the socket to the specified endpoint.
 asio::error_code connect(implementation_type& impl,
     const endpoint_type& peer_endpoint, asio::error_code& ec)
 {
   socket_ops::sync_connect(impl.socket_,
       peer_endpoint.data(), peer_endpoint.size(), ec);
   return ec;
 }
开发者ID:GeorgeShaw,项目名称:resiprocate,代码行数:8,代码来源:reactive_socket_service.hpp


示例4: socket

    explicit
    socket(endpoint_type endpoint) {
        typename endpoint_type::protocol_type protocol = endpoint.protocol();

        m_fd = ::socket(protocol.family(), protocol.type(), protocol.protocol());

        if(m_fd == -1) {
            throw std::system_error(errno, std::system_category(), "unable to create a socket");
        }

        medium_type::configure(m_fd);

        if(::connect(m_fd, endpoint.data(), endpoint.size()) != 0) {
            auto ec = std::error_code(errno, std::system_category());

            ::close(m_fd);

            throw std::system_error(
                ec,
                cocaine::format("unable to connect a socket to '%s'", endpoint)
            );
        }

        ::fcntl(m_fd, F_SETFD, FD_CLOEXEC);
        ::fcntl(m_fd, F_SETFL, O_NONBLOCK);
    }
开发者ID:StrangeTcy,项目名称:cocaine-core,代码行数:26,代码来源:socket.hpp


示例5: bind

  /// Bind the fiber acceptor to the specified local endpoint.
  boost::system::error_code bind(implementation_type& impl,
                                 const endpoint_type& endpoint,
                                 boost::system::error_code& ec) {
    impl->p_fib_demux = &(endpoint.demux());
    impl->p_fib_demux->bind(endpoint.port(), impl, ec);

    return ec;
  }
开发者ID:chrisaljoudi,项目名称:ssf,代码行数:9,代码来源:fiber_acceptor_service.hpp


示例6: pack

    static inline
    void
    pack(msgpack::packer<Stream>& target, const endpoint_type& source) {
        const std::string address = source.address().to_string();
        const unsigned short port = source.port();

        type_traits<tuple_type>::pack(target, tuple_type(address, port));
    }
开发者ID:bdacode,项目名称:cocaine-core,代码行数:8,代码来源:endpoint.hpp


示例7: send_to

  size_t send_to(implementation_type& impl, const ConstBufferSequence& buffers,
      const endpoint_type& destination, socket_base::message_flags flags,
      asio::error_code& ec)
  {
    buffer_sequence_adapter<asio::const_buffer,
        ConstBufferSequence> bufs(buffers);

    return socket_ops::sync_sendto(impl.socket_, impl.state_,
        bufs.buffers(), bufs.count(), flags,
        destination.data(), destination.size(), ec);
  }
开发者ID:GeorgeShaw,项目名称:resiprocate,代码行数:11,代码来源:reactive_socket_service.hpp


示例8: unpack

    static inline
    void
    unpack(const msgpack::object& source, endpoint_type& target) {
        std::string address;
        unsigned short port;

        type_traits<tuple_type>::unpack(source, std::move(std::tie(address, port)));

        target.address(boost::asio::ip::address::from_string(address));
        target.port(port);
    }
开发者ID:bdacode,项目名称:cocaine-core,代码行数:11,代码来源:endpoint.hpp


示例9: resolve

  // Resolve an endpoint to a list of entries.
  iterator_type resolve(implementation_type&,
      const endpoint_type& endpoint, asio::error_code& ec)
  {
    char host_name[NI_MAXHOST];
    char service_name[NI_MAXSERV];
    socket_ops::sync_getnameinfo(endpoint.data(), endpoint.size(),
        host_name, NI_MAXHOST, service_name, NI_MAXSERV,
        endpoint.protocol().type(), ec);

    return ec ? iterator_type() : iterator_type::create(
        endpoint, host_name, service_name);
  }
开发者ID:Almamu,项目名称:evemu_crucible,代码行数:13,代码来源:resolver_service.hpp


示例10: sendto

		ssize_t sendto(
			endpoint_type& to,
			void* buffer,
			size_t len
		)
		{
			return detail::socket_ops::sync_sendto(
				_socket,
				buffer,
				len,
				0,
				to.data(),
				to.size());
		}
开发者ID:romsi,项目名称:NetIO,代码行数:14,代码来源:datagram_socket_service.hpp


示例11: build_request

 virtual request_t build_request(endpoint_type ep, error_code & ec)
 {
     request_t rc = request_t();
     if(!ep.address().is_v4())
     {
         ec = error_code(boost::asio::error::address_family_not_supported);
         return rc;
     }
     rc.detail.version = 4;
     rc.detail.command = 1;
     rc.detail.destination_port = ::htons(ep.port());
     rc.detail.destination_address = ep.address().to_v4().to_bytes();
     rc.detail.end_marker = 0;
     return rc;
 }
开发者ID:houzhenggang,项目名称:libnetpp,代码行数:15,代码来源:socks4.hpp


示例12: recvfrom

		ssize_t recvfrom(
			endpoint_type& from,
			void* buffer,
			size_t len
		)
		{
			socklen_t size = from.size();
			return detail::socket_ops::sync_recvfrom(
				_socket,
				buffer,
				len,
				0,
				from.data(),
				&size);
		}
开发者ID:romsi,项目名称:NetIO,代码行数:15,代码来源:datagram_socket_service.hpp


示例13: async_connect

	void async_connect(endpoint_type const& endpoint, Handler const& handler)
	{
		// make sure we don't try to connect to INADDR_ANY. binding is fine,
		// and using a hostname is fine on SOCKS version 5.
		TORRENT_ASSERT(m_command == socks5_bind
			|| endpoint.address() != address()
			|| (!m_dst_name.empty() && m_version == 5));

		m_remote_endpoint = endpoint;

		// the connect is split up in the following steps:
		// 1. resolve name of proxy server
		// 2. connect to proxy server
		// 3. if version == 5:
		//   3.1 send SOCKS5 authentication method message
		//   3.2 read SOCKS5 authentication response
		//   3.3 send username+password
		// 4. send SOCKS command message

		// to avoid unnecessary copying of the handler,
		// store it in a shaed_ptr
		boost::shared_ptr<handler_type> h(new handler_type(handler));

		ADD_OUTSTANDING_ASYNC("socks5_stream::name_lookup");
		tcp::resolver::query q(m_hostname, to_string(m_port).elems);
		m_resolver.async_resolve(q, boost::bind(
			&socks5_stream::name_lookup, this, _1, _2, h));
	}
开发者ID:UnitedMarsupials,项目名称:libtorrent,代码行数:28,代码来源:socks5_stream.hpp


示例14: async_connect

  void async_connect(implementation_type& impl,
      const endpoint_type& peer_endpoint, Handler& handler)
  {
    // Allocate and construct an operation to wrap the handler.
    typedef win_iocp_socket_connect_op<Handler> op;
    typename op::ptr p = { asio::detail::addressof(handler),
      op::ptr::allocate(handler), 0 };
    p.p = new (p.v) op(impl.socket_, handler);

    ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
          &impl, impl.socket_, "async_connect"));

    start_connect_op(impl, impl.protocol_.family(), impl.protocol_.type(),
        peer_endpoint.data(), static_cast<int>(peer_endpoint.size()), p.p);
    p.v = p.p = 0;
  }
开发者ID:zpzxgcr,项目名称:mongo,代码行数:16,代码来源:win_iocp_socket_service.hpp


示例15: make_error_code

    boost::system::error_code
    bind
        ( endpoint_type const& e )
    {
        // Only fixed port is handled right now.
        if ( e.port() != FIXED_PORT )
            return make_error_code( boost::system::errc::invalid_argument );

        // Generate our local address.
        if ( e.address().is_v4() )
            local_endpoint( generate_unique_ipv4_endpoint( e.port() ) );
        else
            local_endpoint( generate_unique_ipv6_endpoint( e.port() ) );

        add_route_to_socket( local_endpoint(), this );
        return boost::system::error_code();
    }
开发者ID:DavidKeller,项目名称:kademlia,代码行数:17,代码来源:fake_socket.hpp


示例16: receive_from

  size_t receive_from(implementation_type& impl,
      const MutableBufferSequence& buffers,
      endpoint_type& sender_endpoint, socket_base::message_flags flags,
      asio::error_code& ec)
  {
    buffer_sequence_adapter<asio::mutable_buffer,
        MutableBufferSequence> bufs(buffers);

    std::size_t addr_len = sender_endpoint.capacity();
    std::size_t bytes_recvd = socket_ops::sync_recvfrom(
        impl.socket_, impl.state_, bufs.buffers(), bufs.count(),
        flags, sender_endpoint.data(), &addr_len, ec);

    if (!ec)
      sender_endpoint.resize(addr_len);

    return bytes_recvd;
  }
开发者ID:GeorgeShaw,项目名称:resiprocate,代码行数:18,代码来源:reactive_socket_service.hpp


示例17: async_connect

  void async_connect(implementation_type& impl,
      const endpoint_type& peer_endpoint, Handler& handler)
  {
    bool is_continuation =
      asio_handler_cont_helpers::is_continuation(handler);

    // Allocate and construct an operation to wrap the handler.
    typedef reactive_socket_connect_op<Handler> op;
    typename op::ptr p = { asio::detail::addressof(handler),
      op::ptr::allocate(handler), 0 };
    p.p = new (p.v) op(impl.socket_, handler);

    ASIO_HANDLER_CREATION((p.p, "socket", &impl, "async_connect"));

    start_connect_op(impl, p.p, is_continuation,
        peer_endpoint.data(), peer_endpoint.size());
    p.v = p.p = 0;
  }
开发者ID:DevSlashNull,项目名称:MaidSafe,代码行数:18,代码来源:reactive_socket_service.hpp


示例18: connect

 /**
  * This function is used to connect a socket to the specified remote endpoint.
  * The function call will block until the connection is successfully made or
  * an error occurs.
  *
  * The socket is automatically opened if it is not already open. If the
  * connect fails, and the socket was automatically opened, the socket is
  * not returned to the closed state.
  *
  * @param peer_endpoint The remote endpoint to which the socket will be
  * connected.
  *
  * @throws boost::system::system_error Thrown on failure.
  *
  * @par Example
  * @code
  * boost::asio::ip::tcp::socket socket(io_service);
  * boost::asio::ip::tcp::endpoint endpoint(
  *     boost::asio::ip::address::from_string("1.2.3.4"), 12345);
  * socket.connect(endpoint);
  * @endcode
  */
 void connect(const endpoint_type& peer_endpoint)
 {
   boost::system::error_code ec;
   if (!is_open())
   {
     this->service.open(this->implementation, peer_endpoint.protocol(), ec);
     boost::asio::detail::throw_error(ec);
   }
   this->service.connect(this->implementation, peer_endpoint, ec);
   boost::asio::detail::throw_error(ec);
 }
开发者ID:JupiterSmalltalk,项目名称:openqwaq,代码行数:33,代码来源:basic_socket.hpp


示例19: connect

 /**
  * This function is used to connect a socket to the specified remote endpoint.
  * The function call will block until the connection is successfully made or
  * an error occurs.
  *
  * The socket is automatically opened if it is not already open. If the
  * connect fails, and the socket was automatically opened, the socket is
  * not returned to the closed state.
  *
  * @param peer_endpoint The remote endpoint to which the socket will be
  * connected.
  *
  * @throws asio::system_error Thrown on failure.
  *
  * @par Example
  * @code
  * asio::ip::tcp::socket socket(io_service);
  * asio::ip::tcp::endpoint endpoint(
  *     asio::ip::address::from_string("1.2.3.4"), 12345);
  * socket.connect(endpoint);
  * @endcode
  */
 void connect(const endpoint_type& peer_endpoint)
 {
   asio::error_code ec;
   if (!is_open())
   {
     this->get_service().open(this->get_implementation(),
         peer_endpoint.protocol(), ec);
     asio::detail::throw_error(ec, "connect");
   }
   this->get_service().connect(this->get_implementation(), peer_endpoint, ec);
   asio::detail::throw_error(ec, "connect");
 }
开发者ID:AbdelghaniDr,项目名称:Cinder,代码行数:34,代码来源:basic_socket.hpp


示例20: async_send_to

  void async_send_to(implementation_type& impl,
      const ConstBufferSequence& buffers, const endpoint_type& destination,
      socket_base::message_flags flags, Handler& handler)
  {
    // Allocate and construct an operation to wrap the handler.
    typedef win_iocp_socket_send_op<ConstBufferSequence, Handler> op;
    typename op::ptr p = { asio::detail::addressof(handler),
      op::ptr::allocate(handler), 0 };
    p.p = new (p.v) op(impl.cancel_token_, buffers, handler);

    ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
          &impl, impl.socket_, "async_send_to"));

    buffer_sequence_adapter<asio::const_buffer,
        ConstBufferSequence> bufs(buffers);

    start_send_to_op(impl, bufs.buffers(), bufs.count(),
        destination.data(), static_cast<int>(destination.size()),
        flags, p.p);
    p.v = p.p = 0;
  }
开发者ID:zpzxgcr,项目名称:mongo,代码行数:21,代码来源:win_iocp_socket_service.hpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ engine类代码示例发布时间:2022-05-31
下一篇:
C++ emu_timer类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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