PortService class

Web 端 TCP 端口连通性检测服务 / TCP port reachability service for the web.

浏览器禁止任意出站 TCP 连接,因此端口检测在 Web 上不可用;所有方法均返回 表示“不可用”的结果,不抛异常 / Browsers forbid arbitrary outbound TCP connections, so port checks are unavailable on the web; every method returns a result that marks the capability as unavailable instead of throwing.

Constructors

PortService({Duration defaultTimeout = const Duration(seconds: 3)})
构造 PortService / Creates a PortService.
const

Properties

defaultTimeout Duration
单次连接默认超时 / Default timeout of a single connection attempt.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

checkPort({required String host, required int port, Duration? timeout}) Future<PortCheckResult>
检测单个端口是否可连接 / Checks whether a single port accepts connections.
isPortOpen({required String host, required int port, Duration? timeout}) Future<bool>
checkPort 的布尔快捷方式 / Boolean shorthand for checkPort.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
scanPorts({required String host, List<int> ports = const <int>[80, 443], Duration? timeout, int concurrency = 12}) Future<List<PortCheckResult>>
并发扫描多个端口 / Scans multiple ports with bounded concurrency.
toString() String
A string representation of this object.
inherited

Operators

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