Skip to content
DocsTry Aspire
DocsTry

PortAllocator Methods

ClassMethods2 members
Allocates and manages a range of ports for use in an application context.
Marks a port as used to prevent it from being allocated.
public sealed class PortAllocator
{
public void AddUsedPort(
int port)
{
// ...
}
}
portintThe port number to mark as used.
Allocates a port that is not currently in use.
public sealed class PortAllocator
{
public int AllocatePort()
{
// ...
}
}
intAn available port number.