コード例 #1
0
ファイル: IPEndpoint.cs プロジェクト: wandec/ice
        public override IEnumerable <Endpoint> ExpandHost(out Endpoint?publish)
        {
            publish = null;
            // If this endpoint has an empty host (wildcard address), don't expand, just return this endpoint.
            if (Host.Length == 0)
            {
                return(new Endpoint[] { this });
            }

            // If using a fixed port, this endpoint can be used as the published endpoint to access the returned
            // endpoints. Otherwise, we'll publish each individual expanded endpoint.
            publish = Port > 0 ? this : null;

            IEnumerable <IPEndPoint> addresses = Network.GetAddresses(Host,
                                                                      Port,
                                                                      Communicator.IPVersion,
                                                                      EndpointSelectionType.Ordered,
                                                                      Communicator.PreferIPv6);

            if (addresses.Count() == 1)
            {
                return(new Endpoint[] { this });
            }
            else
            {
                return(addresses.Select(address => CreateEndpoint(Network.EndpointAddressToString(address),
                                                                  Network.EndpointPort(address),
                                                                  ConnectionId,
                                                                  HasCompressionFlag,
                                                                  Timeout)));
            }
        }
コード例 #2
0
ファイル: IPEndpoint.cs プロジェクト: rtxlab/ice
        public override IEnumerable <Endpoint> ExpandHost(out Endpoint?publish)
        {
            publish = null;

            // If using a fixed port, this endpoint can be used as the published endpoint to access the returned
            // endpoints. Otherwise, we'll publish each individual expanded endpoint.
            publish = Port > 0 ? this : null;

            IEnumerable <IPEndPoint> addresses = Network.GetAddresses(Host,
                                                                      Port,
                                                                      Network.EnableBoth,
                                                                      EndpointSelectionType.Ordered,
                                                                      Communicator.PreferIPv6);

            if (addresses.Count() == 1)
            {
                return(new Endpoint[] { this });
            }
            else
            {
                return(addresses.Select(address => Clone(address.Address.ToString(), (ushort)address.Port)));
            }
        }