Exemple #1
0
 public IPHostEntryInfo(IPAddressInfo[] ipAddressInfoList, string hostName) {
     HostName = (((object)hostName) == null ? string.Empty : hostName);
     IPAddressInfoList = ipAddressInfoList;
 }
Exemple #2
0
        /*++

            SetAddressList - Set the list of IP addresses for this service point.

            This is a method called when the underlying code has resolved the
            destination to a list of IP addressess. We actually maintain some
            information about the viable IP addresses for this service point,
            like whether or not they're loopback, etc. So we walk through the
            list and set up an array of structures corresponding to the IP
            addresses.

            Note that it's possible to have some IP addresses be loopbacked
            and some not. This can happen if a server name maps to multiple
            physical servers and we're one of those servers.

            Input:
                    addressList     - Array of resolved IP addresses.

            Returns: Nothing.

        --*/
        private IPHostEntryInfo SetAddressList(IPHostEntry ipHostEntry) {
            GlobalLog.Print("SetAddressList("+ipHostEntry.HostName+")");
            //
            // Create an array of IPAddressInfo of the appropriate size, then
            // get a list of our local addresses. Walk through the input
            // address list. Copy each address in the address list into
            // our array, and if the address is a loopback address, mark it as
            // such.
            //
            IPAddress[] addressList = ipHostEntry.AddressList;
            IPAddressInfo[] TempInfo = new IPAddressInfo[addressList.Length];

            //
            // Walk through each member of the input list, copying it into our temp array.
            //
            int i, k;
            IPHostEntry ipLocalHostEntry = Dns.LocalHost;
            for (i = 0; i < addressList.Length; i++) {
                TempInfo[i] = new IPAddressInfo(addressList[i]);

                // First, check to see if the current address is a  loopback
                // address.

                if (IPAddress.IsLoopback(TempInfo[i].Address)) {
                    TempInfo[i].IsLoopback = true;
                    continue;
                }

                // See if the current IP address is a local address, and if
                // so mark it as such.

                for (k = 0; k < ipLocalHostEntry.AddressList.Length; k++) {
                    if (TempInfo[i].Address.Address == ipLocalHostEntry.AddressList[k].Address) {
                        TempInfo[i].IsLoopback = true;
                        break;
                    }
                }
            }

            //
            // now look for connection group objects that don't have
            // an IP address associated with them. When it finds one, it updates
            // the IP address and tries to update the connection limit.
            //
            lock (this) {
                // Walk through the connection groups on this service
                // point, and update the ones we need to with an IP
                // address.
                //

                IDictionaryEnumerator CGEnumerator;

                CGEnumerator = m_ConnectionGroupList.GetEnumerator();

                while (CGEnumerator.MoveNext()) {
                    ConnectionGroup CurrentCG = (ConnectionGroup)CGEnumerator.Value;

                    // If this connection group doesn't have an IP address
                    // assigned to it, give it one.

                    if (CurrentCG.RemoteIPAddress == null) {
                        GlobalLog.Print("ServicePoint::UpdateConnectionGroupAddresses null CurrentCG.RemoteIPAddress");

                        // Update the address.

                        CurrentCG.RemoteIPAddress = TempInfo[0].Address;

                        // Now update the connection limit based on what we know.

                        CurrentCG.InternalConnectionLimit = TempInfo[0].IsLoopback ? LoopbackConnectionLimit : m_ConnectionLimit;

                        GlobalLog.Print("ServicePoint::UpdateConnectionGroupAddresses CurrentCG.InternalConnectionLimit:" + CurrentCG.InternalConnectionLimit.ToString());
                    }

                    GlobalLog.Print("ServicePoint::UpdateConnectionGroupAddresses CurrentCG.RemoteIPAddress:" + CurrentCG.RemoteIPAddress.ToString());
                }
            }

            IPHostEntryInfo ipAddressInfoList = new IPHostEntryInfo(TempInfo, ipHostEntry.HostName);
            return ipAddressInfoList ;
        }