1 type derived from IPAddress
System.Net.Primitives (1)
49 instantiations of IPAddress
Aspire.Hosting.Azure.PostgreSQL (4)
AzurePostgresExtensions.cs (4)
396StartIPAddress = new IPAddress([0, 0, 0, 0]),
397EndIPAddress = new IPAddress([0, 0, 0, 0])
407StartIPAddress = new IPAddress([0, 0, 0, 0]),
408EndIPAddress = new IPAddress([255, 255, 255, 255])
InMemory.FunctionalTests (1)
Microsoft.AspNetCore.InternalTesting (1)
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (2)
Microsoft.Extensions.ServiceDiscovery.Dns (2)
Sockets.BindTests (1)
System.Net.NameResolution (2)
System.Net.NetworkInformation (6)
System.Net.Ping (6)
System.Net.Primitives (9)
System.Net.Quic (2)
System.Net.Sockets (10)
System.Security.Cryptography (1)
TlsFeaturesObserve (1)
UIAutomationClientSideProviders (1)
1004 references to IPAddress
Aspire.Dashboard (2)
Aspire.Dashboard.Tests (4)
Aspire.Hosting (5)
AutobahnTestApp (1)
ClientSample (2)
dotnet-svcutil-lib (18)
http2cat (2)
Http3SampleApp (1)
HttpAbstractions.SampleApp (2)
HttpsPolicySample (2)
IIS.Common.TestLib (3)
IIS.FunctionalTests (3)
IIS.LongTests (3)
IIS.NewHandler.FunctionalTests (3)
IIS.NewShim.FunctionalTests (3)
IISExpress.FunctionalTests (4)
InMemory.FunctionalTests (36)
InProcessWebSite (6)
Interop.FunctionalTests (15)
Http3\Http3RequestTests.cs (7)
1053o.Listen(IPAddress.Parse("127.0.0.1"), port, listenOptions =>
1374o.Listen(IPAddress.Parse("127.0.0.1"), 0, listenOptions =>
1846kestrel.Listen(IPAddress.Parse("127.0.0.1"), 0, listenOptions =>
2015kestrel.Listen(IPAddress.Parse("127.0.0.1"), 0, listenOptions =>
2093IPAddress remoteAddress = null;
2095IPAddress localAddress = null;
2178kestrel.Listen(IPAddress.Loopback, 0, listenOptions =>
Kestrel.SampleApp (3)
LargeResponseApp (1)
Microsoft.AspNetCore.DataProtection.Tests (1)
Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests (2)
Microsoft.AspNetCore.HeaderParsing (6)
Microsoft.AspNetCore.HeaderParsing.Tests (13)
Microsoft.AspNetCore.Http (4)
Microsoft.AspNetCore.Http.Abstractions (4)
Microsoft.AspNetCore.Http.Connections.Tests (4)
Microsoft.AspNetCore.Http.Extensions.Tests (10)
RequestDelegateFactoryTests.cs (6)
332new object[] { (Action<HttpContext, IPAddress[]>)Store, new[] { "127.0.0.1" }, new[] { IPAddress.Loopback } },
333new object[] { (Action<HttpContext, IPEndPoint[]>)Store, new[] { "127.0.0.1:80" },new[] { new IPEndPoint(IPAddress.Loopback, 80) } },
383new object[] { (Action<HttpContext, IPAddress>)Store, "127.0.0.1", IPAddress.Loopback },
384new object[] { (Action<HttpContext, IPEndPoint>)Store, "127.0.0.1:80", new IPEndPoint(IPAddress.Loopback, 80) },
Microsoft.AspNetCore.Http.Features (2)
Microsoft.AspNetCore.HttpOverrides (25)
IPNetwork.cs (17)
18/// Create a new <see cref="IPNetwork"/> with the specified <see cref="IPAddress"/> and prefix length.
20/// <param name="prefix">The <see cref="IPAddress"/>.</param>
23public IPNetwork(IPAddress prefix, int prefixLength) : this(prefix, prefixLength, true)
27private IPNetwork(IPAddress prefix, int prefixLength, bool checkPrefixLengthRange)
42/// Get the <see cref="IPAddress"/> that represents the prefix for the network.
44public IPAddress Prefix { get; }
56/// Determine whether a given The <see cref="IPAddress"/> is part of the IP network.
58/// <param name="address">The <see cref="IPAddress"/>.</param>
59/// <returns><see langword="true"/> if the <see cref="IPAddress"/> is part of the IP network. Otherwise, <see langword="false"/>.</returns>
60public bool Contains(IPAddress address)
98private static bool IsValidPrefixLengthRange(IPAddress prefix, int prefixLength)
123/// <inheritdoc cref="TryParseComponents(ReadOnlySpan{char}, out IPAddress?, out int)"/>
126if (!TryParseComponents(networkSpan, out var prefix, out var prefixLength))
154/// <inheritdoc cref="TryParseComponents(ReadOnlySpan{char}, out IPAddress?, out int)"/>
159if (!TryParseComponents(networkSpan, out var prefix, out var prefixLength))
184[NotNullWhen(true)] out IPAddress? prefix,
196if (!IPAddress.TryParse(networkSpan.Slice(0, forwardSlashIndex), out prefix))
Microsoft.AspNetCore.HttpOverrides.Tests (23)
Microsoft.AspNetCore.Identity.FunctionalTests (1)
Microsoft.AspNetCore.InternalTesting (2)
Microsoft.AspNetCore.Owin (6)
OwinEnvironment.cs (2)
437{ OwinConstants.CommonKeys.LocalIpAddress, new FeatureMap<IHttpConnectionFeature>(feature => feature.LocalIpAddress.ToString(), (feature, value) => feature.LocalIpAddress = IPAddress.Parse(Convert.ToString(value, CultureInfo.InvariantCulture))) },
438{ OwinConstants.CommonKeys.RemoteIpAddress, new FeatureMap<IHttpConnectionFeature>(feature => feature.RemoteIpAddress.ToString(), (feature, value) => feature.RemoteIpAddress = IPAddress.Parse(Convert.ToString(value, CultureInfo.InvariantCulture))) },
Microsoft.AspNetCore.Rewrite.Tests (4)
Microsoft.AspNetCore.Server.HttpSys (11)
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (6)
Microsoft.AspNetCore.Server.HttpSys.Tests (2)
Microsoft.AspNetCore.Server.IIS (9)
Microsoft.AspNetCore.Server.IntegrationTesting (3)
Microsoft.AspNetCore.Server.Kestrel.Core (16)
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (44)
KestrelServerTests.cs (28)
107serverOptions.Listen(new IPEndPoint(IPAddress.Loopback, 0));
145kestrelOptions.Listen(IPAddress.Loopback, 0);
344serverOptions.Listen(new IPEndPoint(IPAddress.Loopback, 0));
360var endpoint = new IPEndPoint(IPAddress.Loopback, 0);
381serverOptions.Listen(new IPEndPoint(IPAddress.Loopback, 0), c =>
401var endpoint = new IPEndPoint(IPAddress.Loopback, 0);
475Assert.Equal(IPAddress.IPv6Any, ((IPEndPoint)transportEndPoint.OriginalEndPoint).Address);
476Assert.Equal(IPAddress.IPv6Any, ((IPEndPoint)multiplexedTransportEndPoint.OriginalEndPoint).Address);
504Assert.Equal(IPAddress.IPv6Any, ((IPEndPoint)transportEndPoint.OriginalEndPoint).Address);
532Assert.Equal(IPAddress.IPv6Any, ((IPEndPoint)multiplexedTransportEndPoint.OriginalEndPoint).Address);
545new ListenOptions(new IPEndPoint(IPAddress.Loopback, 0))
602new ListenOptions(new IPEndPoint(IPAddress.Loopback, 0))
662new ListenOptions(new IPEndPoint(IPAddress.Loopback, 0))
724new ListenOptions(new IPEndPoint(IPAddress.Loopback, 0))
828mockTransportFactory.Verify(f => f.BindAsync(new IPEndPoint(IPAddress.IPv6Any, 5000), It.IsAny<CancellationToken>()), Times.Once);
829mockTransportFactory.Verify(f => f.BindAsync(new IPEndPoint(IPAddress.IPv6Any, 5001), It.IsAny<CancellationToken>()), Times.Once);
830mockTransportFactory.Verify(f => f.BindAsync(new IPEndPoint(IPAddress.IPv6Any, 5002), It.IsAny<CancellationToken>()), Times.Never);
831mockTransportFactory.Verify(f => f.BindAsync(new IPEndPoint(IPAddress.IPv6Any, 5003), It.IsAny<CancellationToken>()), Times.Never);
849mockTransportFactory.Verify(f => f.BindAsync(new IPEndPoint(IPAddress.IPv6Any, 5000), It.IsAny<CancellationToken>()), Times.Once);
850mockTransportFactory.Verify(f => f.BindAsync(new IPEndPoint(IPAddress.IPv6Any, 5001), It.IsAny<CancellationToken>()), Times.Once);
851mockTransportFactory.Verify(f => f.BindAsync(new IPEndPoint(IPAddress.IPv6Any, 5002), It.IsAny<CancellationToken>()), Times.Once);
852mockTransportFactory.Verify(f => f.BindAsync(new IPEndPoint(IPAddress.IPv6Any, 5003), It.IsAny<CancellationToken>()), Times.Once);
878mockTransportFactory.Verify(f => f.BindAsync(new IPEndPoint(IPAddress.IPv6Any, 5000), It.IsAny<CancellationToken>()), Times.Once);
879mockTransportFactory.Verify(f => f.BindAsync(new IPEndPoint(IPAddress.IPv6Any, 5001), It.IsAny<CancellationToken>()), Times.Once);
880mockTransportFactory.Verify(f => f.BindAsync(new IPEndPoint(IPAddress.IPv6Any, 5002), It.IsAny<CancellationToken>()), Times.Once);
881mockTransportFactory.Verify(f => f.BindAsync(new IPEndPoint(IPAddress.IPv6Any, 5003), It.IsAny<CancellationToken>()), Times.Exactly(2));
966mockTransportFactory.Verify(f => f.BindAsync(new IPEndPoint(IPAddress.IPv6Any, 5000), It.IsAny<CancellationToken>()), Times.Once);
967mockTransportFactory.Verify(f => f.BindAsync(new IPEndPoint(IPAddress.IPv6Any, 5001), It.IsAny<CancellationToken>()), Times.Once);
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests (9)
WebHostTests.cs (6)
109o.Listen(IPAddress.Parse("127.0.0.1"), http3Port, listenOptions =>
114o.Listen(IPAddress.Parse("127.0.0.1"), http1Port, listenOptions =>
149o.Listen(IPAddress.Parse("127.0.0.1"), 0, listenOptions =>
186o.Listen(IPAddress.Parse("127.0.0.1"), port, listenOptions =>
224o.Listen(IPAddress.Parse("127.0.0.1"), port, listenOptions =>
295o.Listen(IPAddress.Parse("127.0.0.1"), port, listenOptions =>
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets (1)
Microsoft.AspNetCore.Shared.Tests (5)
Microsoft.AspNetCore.SignalR.Client.Tests (1)
Microsoft.AspNetCore.SignalR.StackExchangeRedis (1)
Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests (1)
Microsoft.AspNetCore.SpaServices.Extensions (1)
Microsoft.AspNetCore.StaticFiles.FunctionalTests (1)
Microsoft.AspNetCore.TestHost.Tests (2)
Microsoft.AspNetCore.Testing (2)
Microsoft.AspNetCore.WebSockets.Tests (1)
Microsoft.DotNet.Build.Tasks.Workloads (6)
Microsoft.Extensions.Diagnostics.Probes (1)
Microsoft.Extensions.Diagnostics.Probes.Tests (2)
Microsoft.Extensions.Diagnostics.ResourceMonitoring (8)
Microsoft.Extensions.Identity.Core (1)
Microsoft.Extensions.ServiceDiscovery (4)
Microsoft.Extensions.ServiceDiscovery.Dns (11)
Resolver\DnsResolver.cs (7)
123res[index] = new AddressResult(DateTime.MaxValue, IPAddress.IPv6Loopback);
128res[index] = new AddressResult(DateTime.MaxValue, IPAddress.Loopback);
161return ValueTask.FromResult<AddressResult[]>([new AddressResult(DateTime.MaxValue, IPAddress.Loopback)]);
165return ValueTask.FromResult<AddressResult[]>([new AddressResult(DateTime.MaxValue, IPAddress.IPv6Loopback)]);
214if (!TryReadAddress(answer, queryType, out IPAddress? address))
262if (!TryReadAddress(answer, queryType, out IPAddress? address))
328static bool TryReadAddress(in DnsResourceRecord record, QueryType type, [NotNullWhen(true)] out IPAddress? target)
Microsoft.Extensions.ServiceDiscovery.Dns.Tests (50)
DnsSrvServiceEndpointResolverTests.cs (8)
44new ServiceResult(DateTime.UtcNow.AddSeconds(60), 99, 66, 8888, "srv-a", [new AddressResult(DateTime.UtcNow.AddSeconds(64), IPAddress.Parse("10.10.10.10"))]),
45new ServiceResult(DateTime.UtcNow.AddSeconds(60), 99, 62, 9999, "srv-b", [new AddressResult(DateTime.UtcNow.AddSeconds(64), IPAddress.IPv6Loopback)]),
70Assert.Equal(new IPEndPoint(IPAddress.Parse("10.10.10.10"), 8888), eps[0].EndPoint);
71Assert.Equal(new IPEndPoint(IPAddress.IPv6Loopback, 9999), eps[1].EndPoint);
95new ServiceResult(DateTime.UtcNow.AddSeconds(60), 99, 66, 8888, "srv-a", [new AddressResult(DateTime.UtcNow.AddSeconds(64), IPAddress.Parse("10.10.10.10"))]),
96new ServiceResult(DateTime.UtcNow.AddSeconds(60), 99, 62, 9999, "srv-b", [new AddressResult(DateTime.UtcNow.AddSeconds(64), IPAddress.IPv6Loopback)]),
151Assert.Equal(new IPEndPoint(IPAddress.Parse("10.10.10.10"), 8888), eps[0].EndPoint);
152Assert.Equal(new IPEndPoint(IPAddress.IPv6Loopback, 9999), eps[1].EndPoint);
Microsoft.Extensions.ServiceDiscovery.Dns.Tests.Fuzzing (1)
Microsoft.Extensions.ServiceDiscovery.Tests (15)
ServiceEndpointResolverTests.cs (13)
93collection.Endpoints.Add(ServiceEndpoint.Create(new IPEndPoint(IPAddress.Parse("127.1.1.1"), 8080)));
98collection.Endpoints.Add(ServiceEndpoint.Create(new IPEndPoint(IPAddress.Parse("127.1.1.2"), 8888)));
118Assert.Equal(IPAddress.Parse("127.1.1.1"), ip.Address);
132Assert.Equal(new IPEndPoint(IPAddress.Parse("127.1.1.1"), 8080), endpoints[0]);
133Assert.Equal(new IPEndPoint(IPAddress.Parse("127.1.1.2"), 8888), endpoints[1]);
145collection.Endpoints.Add(ServiceEndpoint.Create(new IPEndPoint(IPAddress.Parse("127.1.1.1"), 8080)));
150collection.Endpoints.Add(ServiceEndpoint.Create(new IPEndPoint(IPAddress.Parse("127.1.1.2"), 8888)));
167Assert.Equal(IPAddress.Parse("127.1.1.1"), ip.Address);
181collection.Endpoints.Add(ServiceEndpoint.Create(new IPEndPoint(IPAddress.Parse("127.1.1.1"), 8080)));
186collection.Endpoints.Add(ServiceEndpoint.Create(new IPEndPoint(IPAddress.Parse("127.1.1.2"), 8888)));
204Assert.Equal(IPAddress.Parse("127.1.1.1"), ip.Address);
233collection.Endpoints.Add(ServiceEndpoint.Create(new IPEndPoint(IPAddress.Parse("127.1.1.1"), 8080)));
288Assert.Equal(IPAddress.Parse("127.1.1.1"), ip.Address);
Microsoft.Extensions.ServiceDiscovery.Yarp.Tests (3)
YarpServiceDiscoveryTests.cs (3)
277new ServiceResult(DateTime.UtcNow.AddSeconds(60), 99, 66, 8888, "srv-a", [new AddressResult(DateTime.UtcNow.AddSeconds(64), IPAddress.Parse("10.10.10.10"))]),
278new ServiceResult(DateTime.UtcNow.AddSeconds(60), 99, 62, 9999, "srv-b", [new AddressResult(DateTime.UtcNow.AddSeconds(64), IPAddress.IPv6Loopback)]),
279new ServiceResult(DateTime.UtcNow.AddSeconds(60), 99, 62, 7777, "srv-c", [new AddressResult(DateTime.UtcNow.AddSeconds(64), IPAddress.Loopback)])
Microsoft.Gen.Logging.Generated.Tests (4)
netstandard (1)
PlaintextApp (1)
RewriteSample (2)
Sockets.BindTests (64)
src\Servers\Kestrel\test\BindTests\AddressRegistrationTests.cs (55)
57if (!CanBindToEndpoint(IPAddress.Loopback, 5000))
70if (!CanBindToEndpoint(IPAddress.Loopback, 80))
93await RegisterIPEndPoint_StaticPort_Success(IPAddress.Loopback, $"http://127.0.0.1");
100await RegisterIPEndPoint_StaticPort_Success(IPAddress.IPv6Loopback, $"http://[::1]");
137if (!CanBindToEndpoint(IPAddress.Loopback, 5000) || !CanBindToEndpoint(IPAddress.IPv6Loopback, 5000))
150if (!CanBindToEndpoint(IPAddress.Loopback, 80) || !CanBindToEndpoint(IPAddress.IPv6Loopback, 80))
213var ip = IPAddress.Parse(builder.Host);
343private Task RegisterIPEndPoint_StaticPort_Success(IPAddress address, string testUrl)
450if (!CanBindToEndpoint(IPAddress.Loopback, 5000))
463if (!CanBindToEndpoint(IPAddress.Loopback, 5000) || !CanBindToEndpoint(IPAddress.IPv6Loopback, 5000))
475if (!CanBindToEndpoint(IPAddress.Loopback, 5000))
489if (!CanBindToEndpoint(IPAddress.Loopback, 5000) || !CanBindToEndpoint(IPAddress.IPv6Loopback, 5000))
540socket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
575socket.Bind(new IPEndPoint(IPAddress.IPv6Loopback, 0));
613options.Listen(new IPEndPoint(IPAddress.Loopback, 0), listenOptions =>
658options.Listen(new IPEndPoint(IPAddress.Loopback, 0), listenOptions =>
700options.Listen(new IPEndPoint(IPAddress.Loopback, 0), listenOptions =>
801options.Listen(IPAddress.Loopback, port);
822options.Listen(IPAddress.Loopback, port);
851options.Listen(IPAddress.Loopback, port);
852options.Listen(IPAddress.IPv6Loopback, port);
874options.Listen(IPAddress.Loopback, port);
875options.Listen(IPAddress.IPv6Loopback, port);
933var address = addressFamily == AddressFamily.InterNetwork ? IPAddress.Loopback : IPAddress.IPv6Loopback;
943socket.Bind(new IPEndPoint(IPAddress.IPv6Any, 0));
1024foreach (var ip in ipv4Addresses)
1047dataset.Add(new IPEndPoint(IPAddress.Loopback, 0), "http://127.0.0.1");
1048dataset.Add(new IPEndPoint(IPAddress.Loopback, 0), "https://127.0.0.1");
1051dataset.Add(new IPEndPoint(IPAddress.IPv6Loopback, 0), "http://[::1]");
1052dataset.Add(new IPEndPoint(IPAddress.IPv6Loopback, 0), "https://[::1]");
1055dataset.Add(new IPEndPoint(IPAddress.Any, 0), "http://127.0.0.1");
1056dataset.Add(new IPEndPoint(IPAddress.Any, 0), "https://127.0.0.1");
1059dataset.Add(new IPEndPoint(IPAddress.IPv6Any, 0), "http://127.0.0.1");
1060dataset.Add(new IPEndPoint(IPAddress.IPv6Any, 0), "http://[::1]");
1061dataset.Add(new IPEndPoint(IPAddress.IPv6Any, 0), "https://127.0.0.1");
1062dataset.Add(new IPEndPoint(IPAddress.IPv6Any, 0), "https://[::1]");
1069foreach (var ip in ipv4Addresses)
1080foreach (var ip in ipv6Addresses)
1102{ new IPEndPoint(IPAddress.Loopback, 443), "https://127.0.0.1" },
1103{ new IPEndPoint(IPAddress.IPv6Loopback, 443), "https://[::1]" },
1104{ new IPEndPoint(IPAddress.Any, 443), "https://127.0.0.1" },
1105{ new IPEndPoint(IPAddress.IPv6Any, 443), "https://[::1]" }
1123.Where(ip => !ip.Equals(IPAddress.IPv6Loopback))
1128foreach (var ip in ipv6Addresses)
1164foreach (var ip in ipv6Addresses)
1177private static IEnumerable<IPAddress> GetIPAddresses()
1202socket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
1246private static bool CanBindToEndpoint(IPAddress address, int port)
Sockets.FunctionalTests (28)
System (1)
System.Net (1)
System.Net.Http (6)
System.Net.HttpListener (10)
System.Net.NameResolution (83)
System\Net\Dns.cs (68)
40public static IPHostEntry GetHostEntry(IPAddress address)
46if (address.Equals(IPAddress.Any) || address.Equals(IPAddress.IPv6Any))
75if (NameResolutionPal.SupportsGetNameInfo && IPAddress.TryParse(hostNameOrAddress, out IPAddress? address))
77if (address.Equals(IPAddress.Any) || address.Equals(IPAddress.IPv6Any))
152public static Task<IPHostEntry> GetHostEntryAsync(IPAddress address)
158if (address.Equals(IPAddress.Any) || address.Equals(IPAddress.IPv6Any))
167IPHostEntry ipHostEntry = GetHostEntryCore((IPAddress)s, AddressFamily.Unspecified, activity);
168if (NetEventSource.Log.IsEnabled()) NetEventSource.Info((IPAddress)s, $"{ipHostEntry} with {ipHostEntry.AddressList.Length} entries");
173public static IAsyncResult BeginGetHostEntry(IPAddress address, AsyncCallback? requestCallback, object? stateObject) =>
188public static IPAddress[] GetHostAddresses(string hostNameOrAddress)
197/// An array of type <see cref="IPAddress"/> that holds the IP addresses for the host that is specified by the <paramref name="hostNameOrAddress"/> parameter.
199public static IPAddress[] GetHostAddresses(string hostNameOrAddress, AddressFamily family)
204IPAddress[] addresses;
205if (IPAddress.TryParse(hostNameOrAddress, out IPAddress? address))
207if (address.Equals(IPAddress.Any) || address.Equals(IPAddress.IPv6Any))
213addresses = (family == AddressFamily.Unspecified || address.AddressFamily == family) ? new IPAddress[] { address } : Array.Empty<IPAddress>();
224public static Task<IPAddress[]> GetHostAddressesAsync(string hostNameOrAddress) =>
225(Task<IPAddress[]>)GetHostEntryOrAddressesCoreAsync(hostNameOrAddress, justReturnParsedIp: true, throwOnIIPAny: true, justAddresses: true, AddressFamily.Unspecified, CancellationToken.None);
234/// type <see cref="IPAddress"/> that holds the IP addresses for the host that is specified by the <paramref name="hostNameOrAddress"/> parameter.
236public static Task<IPAddress[]> GetHostAddressesAsync(string hostNameOrAddress, CancellationToken cancellationToken) =>
237(Task<IPAddress[]>)GetHostEntryOrAddressesCoreAsync(hostNameOrAddress, justReturnParsedIp: true, throwOnIIPAny: true, justAddresses: true, AddressFamily.Unspecified, cancellationToken);
247/// type <see cref="IPAddress"/> that holds the IP addresses for the host that is specified by the <paramref name="hostNameOrAddress"/> parameter.
249public static Task<IPAddress[]> GetHostAddressesAsync(string hostNameOrAddress, AddressFamily family, CancellationToken cancellationToken = default) =>
250(Task<IPAddress[]>)GetHostEntryOrAddressesCoreAsync(hostNameOrAddress, justReturnParsedIp: true, throwOnIIPAny: true, justAddresses: true, family, cancellationToken);
255public static IPAddress[] EndGetHostAddresses(IAsyncResult asyncResult)
261return TaskToAsyncResult.End<IPAddress[]>(asyncResult);
269if (IPAddress.TryParse(hostName, out IPAddress? address))
298IPHostEntry ipHostEntry = GetHostEntryCore(IPAddress.Parse(address), AddressFamily.Unspecified);
305public static IPHostEntry GetHostByAddress(IPAddress address)
324if (NameResolutionPal.SupportsGetNameInfo && IPAddress.TryParse(hostName, out IPAddress? address) &&
365IPAddress? address = asyncState switch
367IPAddress a => a,
368KeyValuePair<IPAddress, AddressFamily> t => t.Key,
387private static IPAddress[] GetHostAddressesCore(string hostName, AddressFamily addressFamily, NameResolutionActivity? activityOrDefault = default) =>
388(IPAddress[])GetHostEntryOrAddressesCore(hostName, justAddresses: true, addressFamily, activityOrDefault);
397IPAddress[] addresses = Array.Empty<IPAddress>();
435SocketError errorCode = NameResolutionPal.TryGetAddrInfo(hostName, justAddresses, addressFamily, out string? newHostName, out string[] aliases, out IPAddress[] addresses, out int nativeErrorCode);
463private static IPHostEntry GetHostEntryCore(IPAddress address, AddressFamily addressFamily, NameResolutionActivity? activityOrDefault = default) =>
466private static IPAddress[] GetHostAddressesCore(IPAddress address, AddressFamily addressFamily, NameResolutionActivity? activityOrDefault = default) =>
467(IPAddress[])GetHostEntryOrAddressesCore(address, justAddresses: true, addressFamily, activityOrDefault);
470private static object GetHostEntryOrAddressesCore(IPAddress address, bool justAddresses, AddressFamily addressFamily, NameResolutionActivity? activityOrDefault = default)
513errorCode = NameResolutionPal.TryGetAddrInfo(name, justAddresses, addressFamily, out string? hostName, out string[] aliases, out IPAddress[] addresses, out int nativeErrorCode);
558Task.FromCanceled<IPAddress[]>(cancellationToken) :
565Task.FromResult((IPAddress[])resultOnFailure) :
572if (NameResolutionPal.SupportsGetNameInfo && IPAddress.TryParse(hostName, out IPAddress? ipAddress))
574if (throwOnIIPAny && (ipAddress.Equals(IPAddress.Any) || ipAddress.Equals(IPAddress.IPv6Any)))
583Task.FromResult(family == AddressFamily.Unspecified || ipAddress.AddressFamily == family ? new[] { ipAddress } : Array.Empty<IPAddress>()) :
587asyncState = family == AddressFamily.Unspecified ? (object)ipAddress : new KeyValuePair<IPAddress, AddressFamily>(ipAddress, family);
605? GetAddrInfoWithTelemetryAsync<IPAddress[]>(hostName, justAddresses, family, cancellationToken)
630IPAddress a => GetHostAddressesCore(a, AddressFamily.Unspecified, activity),
631KeyValuePair<IPAddress, AddressFamily> t => GetHostAddressesCore(t.Key, t.Value, activity),
641IPAddress a => GetHostEntryCore(a, AddressFamily.Unspecified, activity),
642KeyValuePair<IPAddress, AddressFamily> t => GetHostEntryCore(t.Key, t.Value, activity),
685private static IPHostEntry CreateHostEntryForAddress(IPAddress address) =>
690AddressList = new IPAddress[] { address }
System\Net\NameResolutionPal.Unix.cs (7)
56private static unsafe void ParseHostEntry(Interop.Sys.HostEntry hostEntry, bool justAddresses, out string? hostName, out string[] aliases, out IPAddress[] addresses)
64IPAddress[] localAddresses;
67localAddresses = Array.Empty<IPAddress>();
96localAddresses = new IPAddress[nativeAddressCount];
131public static unsafe SocketError TryGetAddrInfo(string name, bool justAddresses, AddressFamily addressFamily, out string? hostName, out string[] aliases, out IPAddress[] addresses, out int nativeErrorCode)
146addresses = Array.Empty<IPAddress>();
155public static unsafe string? TryGetNameInfo(IPAddress addr, out SocketError socketError, out int nativeErrorCode)
System.Net.NetworkInformation (66)
System.Net.Ping (62)
System\Net\NetworkInformation\Ping.cs (42)
58private void CheckArgs(IPAddress address, int timeout, byte[] buffer)
67if (address.Equals(IPAddress.Any) || address.Equals(IPAddress.IPv6Any))
106private static IPAddress GetAddressSnapshot(IPAddress address)
108IPAddress addressSnapshot = address.AddressFamily == AddressFamily.InterNetwork ?
218/// Attempts to send an Internet Control Message Protocol (ICMP) echo message to the computer that has the specified <see cref="IPAddress"/>,
222/// An <see cref="IPAddress"/> that identifies the computer that is the destination for the ICMP echo message.
232public PingReply Send(IPAddress address)
238/// Attempts to send an Internet Control Message Protocol (ICMP) echo message to the computer that has the specified <see cref="IPAddress"/>,
242/// An <see cref="IPAddress"/> that identifies the computer that is the destination for the ICMP echo message.
256public PingReply Send(IPAddress address, int timeout)
293/// Attempts to send an Internet Control Message Protocol (ICMP) echo message to the computer that has the specified <see cref="IPAddress"/>,
297/// An <see cref="IPAddress"/> that identifies the computer that is the destination for the ICMP echo message.
317public PingReply Send(IPAddress address, int timeout, byte[] buffer)
358if (IPAddress.TryParse(hostNameOrAddress, out IPAddress? address))
369/// Attempts to send an Internet Control Message Protocol (ICMP) echo message to the computer that has the specified <see cref="IPAddress"/>,
373/// An <see cref="IPAddress"/> that identifies the computer that is the destination for the ICMP echo message.
396public PingReply Send(IPAddress address, int timeout, byte[] buffer, PingOptions? options)
402IPAddress addressSnapshot = GetAddressSnapshot(address);
420/// Attempts to send an Internet Control Message Protocol (ICMP) echo message to the computer that has the specified <see cref="IPAddress"/>,
424/// An <see cref="IPAddress"/> that identifies the computer that is the destination for the ICMP echo message.
447public PingReply Send(IPAddress address, TimeSpan timeout, byte[]? buffer = null, PingOptions? options = null) =>
492public void SendAsync(IPAddress address, object? userToken)
497public void SendAsync(IPAddress address, int timeout, object? userToken)
507public void SendAsync(IPAddress address, int timeout, byte[] buffer, object? userToken)
517public void SendAsync(IPAddress address, int timeout, byte[] buffer, PingOptions? options, object? userToken)
533public Task<PingReply> SendPingAsync(IPAddress address)
543public Task<PingReply> SendPingAsync(IPAddress address, int timeout)
553public Task<PingReply> SendPingAsync(IPAddress address, int timeout, byte[] buffer)
563public Task<PingReply> SendPingAsync(IPAddress address, int timeout, byte[] buffer, PingOptions? options)
570/// <see cref="IPAddress"/>, and receives a corresponding ICMP echo reply message from that computer as an asynchronous operation. This
583public Task<PingReply> SendPingAsync(IPAddress address, TimeSpan timeout, byte[]? buffer = null, PingOptions? options = null, CancellationToken cancellationToken = default)
588private Task<PingReply> SendPingAsync(IPAddress address, int timeout, byte[] buffer, PingOptions? options, CancellationToken cancellationToken)
596static (address, cancellationToken) => new ValueTask<IPAddress>(address),
638if (IPAddress.TryParse(hostNameOrAddress, out IPAddress? address))
691IPAddress[] addresses = Dns.GetHostAddresses(hostNameOrAddress);
706Func<TArg, CancellationToken, ValueTask<IPAddress>> getAddress,
719IPAddress address = await getAddress(getAddressArg, _timeoutOrCancellationSource.Token).ConfigureAwait(false);
738private static void TestIsIpSupported(IPAddress ip)
System\Net\NetworkInformation\Ping.PingUtility.cs (6)
18private Process GetPingProcess(IPAddress address, byte[] buffer, int timeout, PingOptions? options)
51private PingReply SendWithPingUtility(IPAddress address, byte[] buffer, int timeout, PingOptions? options)
74private async Task<PingReply> SendWithPingUtilityAsync(IPAddress address, byte[] buffer, int timeout, PingOptions? options)
108private static PingReply ParsePingUtilityOutput(IPAddress address, int exitCode, string stdout)
141IPAddress? address;
142if (addressStart < 5 || addressLength <= 0 || !IPAddress.TryParse(stdout.AsSpan(addressStart, addressLength), out address))
System\Net\NetworkInformation\Ping.RawSocket.cs (8)
22private static readonly ushort DontFragment = OperatingSystem.IsFreeBSD() ? (ushort)IPAddress.HostToNetworkOrder((short)0x4000) : (ushort)0x4000;
24private static SocketConfig GetSocketConfig(IPAddress address, byte[] buffer, int timeout, PingOptions? options)
43iph.TotalLength = OperatingSystem.IsFreeBSD() ? (ushort)IPAddress.HostToNetworkOrder((short)totalLength) : (ushort)totalLength;
245IPAddress address = ((IPEndPoint)socketConfig.EndPoint).Address;
250private static PingReply SendIcmpEchoRequestOverRawSocket(IPAddress address, byte[] buffer, int timeout, PingOptions? options)
300private static PingReply CreatePingReplyForUnreachableHost(IPAddress address, Socket socket)
322private async Task<PingReply> SendIcmpEchoRequestOverRawSocketAsync(IPAddress address, byte[] buffer, int timeout, PingOptions? options)
387private static PingReply CreatePingReply(IPStatus status, IPAddress? address = null, long rtt = 0)
System.Net.Primitives (80)
System\Net\IPAddress.cs (37)
20public class IPAddress : ISpanFormattable, ISpanParsable<IPAddress>, IUtf8SpanFormattable, IUtf8SpanParsable<IPAddress>
22public static readonly IPAddress Any = new ReadOnlyIPAddress([0, 0, 0, 0]);
23public static readonly IPAddress Loopback = new ReadOnlyIPAddress([127, 0, 0, 1]);
24public static readonly IPAddress Broadcast = new ReadOnlyIPAddress([255, 255, 255, 255]);
25public static readonly IPAddress None = Broadcast;
29public static readonly IPAddress IPv6Any = new ReadOnlyIPAddress([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 0);
30public static readonly IPAddress IPv6Loopback = new ReadOnlyIPAddress([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], 0);
31public static readonly IPAddress IPv6None = IPv6Any;
33private static readonly IPAddress s_loopbackMappedToIPv6 = new ReadOnlyIPAddress([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 127, 0, 0, 1], 0);
119/// Initializes a new instance of the <see cref='System.Net.IPAddress'/>
227/// <summary>Determines whether the provided span contains a valid <see cref="IPAddress"/>.</summary>
231/// <summary>Determines whether the provided span contains a valid <see cref="IPAddress"/>.</summary>
237/// Converts an IP address string to an <see cref='System.Net.IPAddress'/> instance.
240public static bool TryParse([NotNullWhen(true)] string? ipString, [NotNullWhen(true)] out IPAddress? address)
258public static bool TryParse(ReadOnlySpan<byte> utf8Text, [NotNullWhen(true)] out IPAddress? result)
264public static bool TryParse(ReadOnlySpan<char> ipSpan, [NotNullWhen(true)] out IPAddress? address)
271static bool IUtf8SpanParsable<IPAddress>.TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, [NotNullWhen(true)] out IPAddress? result) =>
275static bool IParsable<IPAddress>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [NotNullWhen(true)] out IPAddress? result) =>
280static bool ISpanParsable<IPAddress>.TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, [NotNullWhen(true)] out IPAddress? result) =>
284public static IPAddress Parse(string ipString)
296public static IPAddress Parse(ReadOnlySpan<byte> utf8Text)
301public static IPAddress Parse(ReadOnlySpan<char> ipSpan)
307static IPAddress IUtf8SpanParsable<IPAddress>.Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider) =>
312static IPAddress ISpanParsable<IPAddress>.Parse(ReadOnlySpan<char> s, IFormatProvider? provider) =>
317static IPAddress IParsable<IPAddress>.Parse(string s, IFormatProvider? provider) =>
565public static bool IsLoopback(IPAddress address)
682return comparand is IPAddress address && Equals(address);
685internal bool Equals(IPAddress comparand)
739public IPAddress MapToIPv6()
757public IPAddress MapToIPv4()
System.Net.Quic (11)
System.Net.Requests (6)
System.Net.Security (4)
System.Net.Sockets (87)
System\Net\Sockets\Socket.Tasks.cs (8)
109public Task ConnectAsync(IPAddress address, int port) => ConnectAsync(new IPEndPoint(address, port));
118public ValueTask ConnectAsync(IPAddress address, int port, CancellationToken cancellationToken) => ConnectAsync(new IPEndPoint(address, port), cancellationToken);
126public Task ConnectAsync(IPAddress[] addresses, int port) => ConnectAsync(addresses, port, CancellationToken.None).AsTask();
135public ValueTask ConnectAsync(IPAddress[] addresses, int port, CancellationToken cancellationToken)
165async ValueTask Core(IPAddress[] addresses, int port, CancellationToken cancellationToken)
169foreach (IPAddress address in addresses)
216EndPoint ep = IPAddress.TryParse(host, out IPAddress? parsedAddress) ? (EndPoint)
System\Net\Sockets\SocketTaskExtensions.cs (4)
28public static Task ConnectAsync(this Socket socket, IPAddress address, int port) =>
31public static ValueTask ConnectAsync(this Socket socket, IPAddress address, int port, CancellationToken cancellationToken) =>
34public static Task ConnectAsync(this Socket socket, IPAddress[] addresses, int port) =>
37public static ValueTask ConnectAsync(this Socket socket, IPAddress[] addresses, int port, CancellationToken cancellationToken) =>
System\Net\Sockets\TCPClient.cs (8)
143public void Connect(IPAddress address, int port)
173public void Connect(IPAddress[] ipAddresses, int port)
184public Task ConnectAsync(IPAddress address, int port) =>
190public Task ConnectAsync(IPAddress[] addresses, int port) =>
207public ValueTask ConnectAsync(IPAddress address, int port, CancellationToken cancellationToken) =>
213public ValueTask ConnectAsync(IPAddress[] addresses, int port, CancellationToken cancellationToken) =>
231public IAsyncResult BeginConnect(IPAddress address, int port, AsyncCallback? requestCallback, object? state) =>
237public IAsyncResult BeginConnect(IPAddress[] addresses, int port, AsyncCallback? requestCallback, object? state) =>
System.Net.WebProxy (4)
System.Security.Cryptography (9)
System.ServiceModel.NetTcp (19)
SystemdTestApp (2)
UIAutomationClientSideProviders (2)
UnitTests.Common (3)
WebTransportInteractiveSampleApp (2)
WebTransportSampleApp (1)
WsFedSample (1)