public WebSocketServer(string url)
        {
            Uri    uri;
            string str;

            if (url == null)
            {
                throw new ArgumentNullException("url");
            }
            if (url.Length == 0)
            {
                throw new ArgumentException("An empty string.", "url");
            }
            if (!WebSocketServer.tryCreateUri(url, out uri, out str))
            {
                throw new ArgumentException(str, "url");
            }
            string    dnsSafeHost = uri.DnsSafeHost;
            IPAddress pAddress    = dnsSafeHost.ToIPAddress();

            if (!pAddress.IsLocal())
            {
                throw new ArgumentException(string.Concat("The host part isn't a local host name: ", url), "url");
            }
            this.init(dnsSafeHost, pAddress, uri.Port, uri.Scheme == "wss");
        }
Exemplo n.º 2
0
        public WebSocketServer(string url)
        {
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }
            string message;

            if (!WebSocketServer.tryCreateUri(url, out this._uri, out message))
            {
                throw new ArgumentException(message, "url");
            }
            string dnsSafeHost = this._uri.DnsSafeHost;

            this._address = dnsSafeHost.ToIPAddress();
            if (this._address == null || !this._address.IsLocal())
            {
                throw new ArgumentException("The host part must be the local host name: " + dnsSafeHost, "url");
            }
            this._port   = this._uri.Port;
            this._secure = (this._uri.Scheme == "wss");
            this.init();
        }