internal ResolveEntry(string host, int port, EndpointSelectionType selType, IPEndpoint endpoint, IEndpointConnectors callback)
 {
     Host     = host;
     Port     = port;
     SelType  = selType;
     Endpoint = endpoint;
     Callback = callback;
 }
        public void Resolve(string host, int port, EndpointSelectionType selType, IPEndpoint endpoint,
                            IEndpointConnectors callback)
        {
            //
            // Try to get the addresses without DNS lookup. If this doesn't work, we queue a resolve
            // entry and the thread will take care of getting the endpoint addresses.
            //
            INetworkProxy?networkProxy = NetworkProxy;

            if (networkProxy == null)
            {
                try
                {
                    List <EndPoint> addrs = Network.GetAddresses(host, port, IPVersion, selType, PreferIPv6, false);
                    if (addrs.Count > 0)
                    {
                        callback.Connectors(endpoint.Connectors(addrs, null));
                        return;
                    }
                }
                catch (LocalException ex)
                {
                    callback.Exception(ex);
                    return;
                }
            }

            lock (_endpointHostResolverThread)
            {
                Debug.Assert(!_endpointHostResolverDestroyed);

                var entry = new ResolveEntry(host, port, selType, endpoint, callback);

                Instrumentation.ICommunicatorObserver?obsv = Observer;
                if (obsv != null)
                {
                    entry.Observer = obsv.GetEndpointLookupObserver(endpoint);
                    if (entry.Observer != null)
                    {
                        entry.Observer.Attach();
                    }
                }

                _enpointHostResolverQueue.AddLast(entry);
                Monitor.Pulse(_endpointHostResolverThread);
            }
        }