ReservedPort class final

A loopback port that is held but not served — "VS Code is not running" on a port nobody else can take.

The obvious way to get a port with nothing on it is to bind port 0, note the number and close the socket. That releases the port, and until the test aims at it anything on the machine may bind it — another run of this same suite, whose fake servers bind ephemeral ports, is the likely one, and a stranger that answers the discovery handshake turns "unavailable" into "available" for reasons the test cannot see. So the socket stays bound, and every connection is closed at once: to a client that is indistinguishable from no server, and serve later turns the same socket into one.

Properties

hashCode → int
The hash code for this object.
no setterinherited
port → int
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
release() → Future<void>
serve({List<String> replies = const ['Hello from the fixture.'], FakeAiServerBehaviour behaviour = FakeAiServerBehaviour.succeed, String workspaceName = 'agent-sdk-fixture'}) → FakeAiServer
Starts answering on this port as a FakeAiServer.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

bind() → Future<ReservedPort>