Exemple #1
0
        public ReadOnlyCollection <IPAddress> SortAddresses(ReadOnlyCollection <IPAddress> addresses)
        {
            ReadOnlyCollection <IPAddress> onlys = SocketAddressList.SortAddresses(this.ipv6Socket, this.listenAddress, addresses);

            if (this.listenAddress != null)
            {
                if (this.listenAddress.IsIPv6LinkLocal)
                {
                    foreach (IPAddress address in onlys)
                    {
                        if (address.IsIPv6LinkLocal)
                        {
                            address.ScopeId = this.listenAddress.ScopeId;
                        }
                    }
                    return(onlys);
                }
                if (!this.listenAddress.IsIPv6SiteLocal)
                {
                    return(onlys);
                }
                foreach (IPAddress address2 in onlys)
                {
                    if (address2.IsIPv6SiteLocal)
                    {
                        address2.ScopeId = this.listenAddress.ScopeId;
                    }
                }
            }
            return(onlys);
        }
Exemple #2
0
        // Sorts the collection of addresses using sort ioctl
        public ReadOnlyCollection <IPAddress> SortAddresses(ReadOnlyCollection <IPAddress> addresses)
        {
            ReadOnlyCollection <IPAddress> sortedAddresses = SocketAddressList.SortAddresses(this.ipv6Socket, listenAddress, addresses);

            // If listening on specific address, copy the scope ID that we're listing on for the
            // link and site local addresses in the sorted list (so that the connect will work)
            if (this.listenAddress != null)
            {
                if (this.listenAddress.IsIPv6LinkLocal)
                {
                    foreach (IPAddress address in sortedAddresses)
                    {
                        if (address.IsIPv6LinkLocal)
                        {
                            address.ScopeId = this.listenAddress.ScopeId;
                        }
                    }
                }
                else if (this.listenAddress.IsIPv6SiteLocal)
                {
                    foreach (IPAddress address in sortedAddresses)
                    {
                        if (address.IsIPv6SiteLocal)
                        {
                            address.ScopeId = this.listenAddress.ScopeId;
                        }
                    }
                }
            }
            return(sortedAddresses);
        }