bind static method

Future<DtlsClient> bind(
  1. dynamic host,
  2. int port, {
  3. bool reuseAddress = true,
  4. bool reusePort = false,
  5. int ttl = 1,
  6. DynamicLibrary? libSsl,
  7. DynamicLibrary? libCrypto,
  8. String? cryptoPath,
  9. String? sslPath,
})

Binds a DtlsClient to the given host and port.

Uses a RawDatagramSocket internally and passes the host, port, reusePort, reuseAddress, and ttl arguments to it.

If you want to load libSsl or libCrypto yourself (e.g., from a custom path), you can pass custom OpenSslFfi objects to this constructor.

Implementation

static Future<DtlsClient> bind(
  dynamic host,
  int port, {
  bool reuseAddress = true,
  bool reusePort = false,
  int ttl = 1,
  DynamicLibrary? libSsl,
  DynamicLibrary? libCrypto,
  String? cryptoPath,
  String? sslPath,
}) async {
  final socket = await RawDatagramSocket.bind(
    host,
    port,
    reuseAddress: reuseAddress,
    reusePort: reusePort,
    ttl: ttl,
  );

  return DtlsClient(socket, libSsl: libSsl, libCrypto: libCrypto, cryptoPath: cryptoPath, sslPath: sslPath)
    .._externalSocket = false;
}