start method

  1. @override
Future<void> start()
override

Starts the transport.

This method binds the socket to the specified address and starts listening for incoming datagrams. It also sets up a listener to handle incoming data.

Implementation

@override
Future<void> start() async {
  try {
    // Bind the socket if it hasn't been bound already.
    _socket ??= await RawDatagramSocket.bind(
      bindAddress.address,
      bindAddress.port,
      ttl: ttl,
    );

    // Start listening for incoming data.
    _socket?.listen(_onData);
  } on Object catch (e) {
    // Log any errors that occur during startup.
    logger?.call(e.toString());
  }
}