Пример #1
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="hostName">Host name.</param>
        /// <param name="protocol">Bind protocol.</param>
        /// <param name="ip">IP address to listen.</param>
        /// <param name="port">Port to listen.</param>
        /// <param name="sslMode">Specifies SSL mode.</param>
        /// <param name="certificate">Certificate to use for SSL connections.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>ip</b> is null.</exception>
        /// <exception cref="ArgumentException">Is raised when any of the arguments has invalid value.</exception>
        public IPBindInfo(string hostName, BindProtocol protocol, IPAddress ip, int port, SslMode sslMode, X509Certificate2 certificate)
        {
            AssertUtil.ArgumentNotNull(ip, nameof(ip));
            AssertUtil.AssertNetworkPort(port, nameof(port));

            this.HostName = hostName;
            this.Protocol = protocol;
            this.EndPoint = new IPEndPoint(ip, port);

            this.SslMode     = sslMode;
            this.Certificate = certificate;
            if ((sslMode == SslMode.SSL || sslMode == SslMode.TLS) && certificate == null)
            {
                throw new ArgumentException($"SSL requested, but argument '{nameof(certificate)}' is not provided.");
            }
        }
Пример #2
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="hostName">Host name.</param>
 /// <param name="protocol">Bind protocol.</param>
 /// <param name="ip">IP address to listen.</param>
 /// <param name="port">Port to listen.</param>
 /// <exception cref="ArgumentNullException">Is raised when <b>ip</b> is null.</exception>
 public IPBindInfo(string hostName, BindProtocol protocol, IPAddress ip, int port)
     : this(hostName, protocol, ip, port, SslMode.None, null)
 {
 }