void converting_move_construct(implementation_type& impl,
      winrt_ssocket_service<Protocol1>&,
      typename winrt_ssocket_service<
        Protocol1>::implementation_type& other_impl)
  {
    this->base_move_construct(impl, other_impl);

    impl.protocol_ = protocol_type(other_impl.protocol_);
    other_impl.protocol_ = typename Protocol1::endpoint().protocol();
  }
 /**
  * This function opens the socket acceptor so that it will use the specified
  * protocol.
  *
  * @param protocol An object specifying which protocol is to be used.
  *
  * @throws lslboost::system::system_error Thrown on failure.
  *
  * @par Example
  * @code
  * lslboost::asio::ip::tcp::acceptor acceptor(io_service);
  * acceptor.open(lslboost::asio::ip::tcp::v4());
  * @endcode
  */
 void open(const protocol_type& protocol = protocol_type())
 {
     lslboost::system::error_code ec;
     this->get_service().open(this->get_implementation(), protocol, ec);
     lslboost::asio::detail::throw_error(ec, "open");
 }
Пример #3
0
static int
parse_option(char *option, flowop_t *flowop)
{
	char *key;	/* Key option */
	char *value;	/* Value for the key */
	char *tmp;
	char err[128];
	if (strcasecmp(option, "tcp_nodelay") == 0) {
		flowop->options.flag |= O_TCP_NODELAY;
		return (UPERF_SUCCESS);
	} else if (strcasecmp(option, "busy") == 0) {
		flowop->options.flag |= O_THINK_BUSY;
		return (UPERF_SUCCESS);
	} else if (strcasecmp(option, "idle") == 0) {
		flowop->options.flag |= O_THINK_IDLE;
		return (UPERF_SUCCESS);
	} else if (strcasecmp(option, "canfail") == 0) {
		flowop->options.flag |= O_CANFAIL;
		return (UPERF_SUCCESS);
	} else if (strcasecmp(option, "non_blocking") == 0) {
		flowop->options.flag |= O_NONBLOCKING;
		return (UPERF_SUCCESS);
	} else {
		key = strtok(option, "=");
		value = strtok(NULL, " ");

		if (value == NULL) {
			snprintf(err, sizeof (err),
				"option %s is not of type key=value\n",
				option);
			add_error(err);
			return (1);
		}

		if (value[0] == '$') {
			tmp = getenv(&value[1]);
			if (tmp == NULL) {
				snprintf(err, sizeof (err),
					"Env variable %s = %s not set\n",
					key, value);
				add_error(err);
				return (1);
			}
			value = tmp;
		}

		if (strcasecmp(key, "size") == 0) {
			flowop->options.size = parse_size(flowop, value);
			if (flowop->options.size == -1) {
				snprintf(err, sizeof (err),
				    "Could not parse %s\n", value);
				add_error(err);
				return (1);
			}
		} else if (strcasecmp(key, "rsize") == 0) {
			flowop->options.rsize = string2int(value);
		} else if (strcasecmp(key, "nfiles") == 0) {
			flowop->options.nfiles = string2int(value);
		} else if (strcasecmp(key, "dir") == 0) {
			strlcpy(flowop->options.dir, value, PATHMAX);
			if (sendfile_init(value) != 0) {
				snprintf(err, sizeof (err),
					"Error initializing dir: %s\n",
					value);
				add_error(err);
				return (1);
			}
		} else if (strcasecmp(key, "count") == 0) {
			flowop->options.count = atoi(value);
		} else if (strcasecmp(key, "port") == 0) {
			flowop->options.port = atoi(value);
		} else if (strcasecmp(key, "protocol") == 0) {
			flowop->options.protocol = protocol_type(value);
			if (protocol_type(value) == PROTOCOL_UNSUPPORTED) {
				snprintf(err, sizeof (err),
					"Protocol %s not supported\n",
					value);
				add_error(err);
				return (1);
			}
		} else if (strcasecmp(key, "conn") == 0) {
			if ((flowop->p_id = atoi(value)) <= 0) {
				snprintf(err, sizeof (err),
				    "connection id (conn=%s) should be > 0\n",
				    value);
				add_error(err);
				return (1);
			}
		} else if (strcasecmp(key, "remotehost") == 0) {
			strlcpy(flowop->options.remotehost, value, 256);
		} else if (strcasecmp(key, "localhost") == 0) {
			strlcpy(flowop->options.localhost, value, 256);
		} else if (strcasecmp(key, "wndsz") == 0) {
			flowop->options.wndsz = string2int(value);
		} else if (strcasecmp(key, "timeout") == 0) {
			flowop->options.poll_timeout = string2nsec(value);
			if (flowop->options.poll_timeout == 0) {
				snprintf(err, sizeof (err),
					"Cannot understand timeout:%s\n",
					value);
				add_error(err);
				return (1);
			}
		} else if (strcasecmp(key, "duration") == 0) {
			flowop->options.duration = string2nsec(value);
			if (flowop->options.duration == 0) {
				snprintf(err, sizeof (err),
					"Cannot understand duration:%s\n",
					value);
				add_error(err);
				return (1);
			}
		}
#ifdef HAVE_SSL
		else if (strcasecmp(key, "engine") == 0) {
			strlcpy(flowop->options.engine, value,
				sizeof (flowop->options.engine));
		} else if (strcasecmp(key, "cipher") == 0) {
			strcpy(flowop->options.cipher, value);
		} else if (strcasecmp(key, "method") == 0) {
			strcpy(flowop->options.method, value);
		}
#endif
		else {
			snprintf(err, sizeof (err),
				"parser - Option unrecognized %s=%s",
				key, value);
			add_error(err);
			return (1);
		}
	}
	return (0);
}
Пример #4
0
 protocol_type protocol() const noexcept
 {
     return protocol_type();
 }