// Assign a native socket to a socket implementation.
 asio::error_code assign(implementation_type& impl,
     const protocol_type& protocol, const native_handle_type& native_socket,
     asio::error_code& ec)
 {
   if (!do_assign(impl, protocol.type(), native_socket, ec))
     impl.protocol_ = protocol;
   return ec;
 }
 // Open a new socket implementation.
 asio::error_code open(implementation_type& impl,
     const protocol_type& protocol, asio::error_code& ec)
 {
   if (!do_open(impl, protocol.family(),
         protocol.type(), protocol.protocol(), ec))
     impl.protocol_ = protocol;
   return ec;
 }
Ejemplo n.º 3
0
 void open(implementation_type& impl, const protocol_type& protocol,
     Error_Handler error_handler)
 {
   if (protocol.type() == SOCK_STREAM)
     service_impl_.open(impl, protocol, error_handler);
   else
     error_handler(asio::error(asio::error::invalid_argument));
 }
Ejemplo n.º 4
0
 // Assign a native socket to a socket implementation.
 asio::error_code assign(implementation_type& impl,
     const protocol_type& protocol, const native_handle_type& native_socket,
     asio::error_code& ec)
 {
   if (!do_assign(impl, protocol.type(), native_socket, ec))
   {
     impl.protocol_ = protocol;
     impl.have_remote_endpoint_ = native_socket.have_remote_endpoint();
     impl.remote_endpoint_ = native_socket.remote_endpoint();
   }
   return ec;
 }
Ejemplo n.º 5
0
 // Open a new socket implementation.
 asio::error_code open(implementation_type& impl,
     const protocol_type& protocol, asio::error_code& ec)
 {
   if (!do_open(impl, protocol.family(),
         protocol.type(), protocol.protocol(), ec))
   {
     impl.protocol_ = protocol;
     impl.have_remote_endpoint_ = false;
     impl.remote_endpoint_ = endpoint_type();
   }
   return ec;
 }
Ejemplo n.º 6
0
 /**
  * This constructor is typically used to perform name resolution for local
  * service binding with a specific protocol version.
  *
  * @param protocol A protocol object, normally representing either the IPv4 or
  * IPv6 version of an internet protocol.
  *
  * @param service_name A string identifying the requested service. This may
  * be a descriptive name or a numeric string corresponding to a port number.
  *
  * @param resolve_flags A set of flags that determine how name resolution
  * should be performed. The default flags are suitable for local service
  * binding.
  *
  * @note On POSIX systems, service names are typically defined in the file
  * <tt>/etc/services</tt>. On Windows, service names may be found in the file
  * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
  * may use additional locations when resolving service names.
  */
 basic_resolver_query(const protocol_type& protocol,
     const std::string& service_name,
     resolver_query_base::flags resolve_flags = passive | address_configured)
   : hints_(),
     host_name_(),
     service_name_(service_name)
 {
   hints_.ai_flags = static_cast<int>(resolve_flags);
   hints_.ai_family = protocol.family();
   hints_.ai_socktype = protocol.type();
   hints_.ai_protocol = protocol.protocol();
   hints_.ai_addrlen = 0;
   hints_.ai_canonname = 0;
   hints_.ai_addr = 0;
   hints_.ai_next = 0;
 }
 /// Construct with specified host name and service name for a given protocol.
 basic_resolver_query(const protocol_type& protocol,
     const std::string& host_name, const std::string& service_name,
     int flags = address_configured)
   : hints_(),
     host_name_(host_name),
     service_name_(service_name)
 {
   hints_.ai_flags = flags;
   hints_.ai_family = protocol.family();
   hints_.ai_socktype = protocol.type();
   hints_.ai_protocol = protocol.protocol();
   hints_.ai_addrlen = 0;
   hints_.ai_canonname = 0;
   hints_.ai_addr = 0;
   hints_.ai_next = 0;
 }