startConnect 静态方法

Future<ConnectionTask<Socket>> startConnect(
  1. dynamic host,
  2. int port,
  3. {dynamic sourceAddress,
  4. int sourcePort = 0}
)

connect 类似,但返回一个 Future,该 Future 在 Socket 不再需要时可以进行取消。

实现

static Future<ConnectionTask<Socket>> startConnect(host, int port,
    {sourceAddress, int sourcePort = 0}) {
  final IOOverrides? overrides = IOOverrides.current;
  if (overrides == null) {
    return Socket._startConnect(host, port,
        sourceAddress: sourceAddress, sourcePort: sourcePort);
  }
  return overrides.socketStartConnect(host, port,
      sourceAddress: sourceAddress, sourcePort: sourcePort);
}