bind static method

Future<DtlsClient> bind(
  1. dynamic host,
  2. int port, {
  3. bool reusePort = false,
  4. bool reuseAddress = true,
  5. int ttl = 1,
  6. int maxTimeoutSeconds = 60,
  7. TinyDTLS? tinyDtls,
})

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.

During connection, the client uses a default maximal timeout of 60 seconds for each handshake exchange and will resend messages during each exchange with an increasing delay. The total time span used for the timeout of message exchanges can be set with the maxTimeoutSeconds argument.

Implementation

static Future<DtlsClient> bind(dynamic host, int port,
    {bool reusePort = false,
    bool reuseAddress = true,
    int ttl = 1,
    int maxTimeoutSeconds = 60,
    TinyDTLS? tinyDtls}) async {
  final socket = await RawDatagramSocket.bind(host, port,
      reusePort: reusePort, reuseAddress: reuseAddress, ttl: ttl);
  return DtlsClient(socket,
      maxTimeoutSeconds: maxTimeoutSeconds, tinyDTLS: tinyDtls)
    .._externalSocket = false;
}