Soenneker.Utils.Network
4.0.1228
Prefix Reserved
dotnet add package Soenneker.Utils.Network --version 4.0.1228
NuGet\Install-Package Soenneker.Utils.Network -Version 4.0.1228
<PackageReference Include="Soenneker.Utils.Network" Version="4.0.1228" />
<PackageVersion Include="Soenneker.Utils.Network" Version="4.0.1228" />
<PackageReference Include="Soenneker.Utils.Network" />
paket add Soenneker.Utils.Network --version 4.0.1228
#r "nuget: Soenneker.Utils.Network, 4.0.1228"
#:package Soenneker.Utils.Network@4.0.1228
#addin nuget:?package=Soenneker.Utils.Network&version=4.0.1228
#tool nuget:?package=Soenneker.Utils.Network&version=4.0.1228
Soenneker.Utils.Network
Checks active local TCP listeners and asks the operating system for an available loopback port candidate.
Installation
dotnet add package Soenneker.Utils.Network
Quick start
using Soenneker.Utils.Network.Registrars;
services.AddNetworkUtilAsSingleton();
Then inject INetworkUtil wherever you need it.
Common operations
if (networkUtil.IsPortBusy(5000))
{
// A local TCP listener was present in the snapshot.
}
int candidatePort = networkUtil.GetFreePort();
IsPortBusy compares the requested number with the operating system's active TCP listener
snapshot. It does not test UDP, remote hosts, firewall reachability, or whether the current process
can bind a particular address. The result can change immediately after the call.
GetFreePort asks the operating system to bind port zero on IPv4 loopback, reads the assigned port,
then closes the listener before returning. The returned number is therefore a candidate, not a
reservation: another thread or process can claim it before the caller binds. For reliable server
startup, bind port zero on the actual server listener and keep that listener open instead of using
a check-then-bind sequence.
Both methods can surface socket or operating-system errors. The utility contains no mutable network state, so scoped and singleton registration are both available; choose the lifetime needed by its consumers.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Soenneker.Extensions.Enumerable (>= 4.0.658)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Utils.Network:
| Package | Downloads |
|---|---|
|
Soenneker.Playwrights.TestEnvironment
A test environment for testing with Playwright |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.1228 | 631 | 8/31/2026 |
| 4.0.1227 | 87 | 8/31/2026 |
| 4.0.1226 | 76 | 8/30/2026 |
| 4.0.1225 | 79 | 8/30/2026 |
| 4.0.1224 | 79 | 8/30/2026 |
| 4.0.1223 | 82 | 8/30/2026 |
| 4.0.1222 | 74 | 8/30/2026 |
| 4.0.1221 | 74 | 8/29/2026 |
| 4.0.1220 | 91 | 8/29/2026 |
| 4.0.1219 | 84 | 8/29/2026 |
| 4.0.1218 | 79 | 8/29/2026 |
| 4.0.1217 | 583 | 8/26/2026 |
| 4.0.1216 | 131 | 8/25/2026 |
| 4.0.1215 | 960 | 8/12/2026 |
| 4.0.1214 | 1,202 | 7/28/2026 |
| 4.0.1213 | 115 | 7/28/2026 |
| 4.0.1212 | 99 | 7/28/2026 |
| 4.0.1211 | 843 | 7/18/2026 |
| 4.0.1210 | 302 | 7/16/2026 |
| 4.0.1209 | 107 | 7/16/2026 |
Clarify network operations