send method

void send(
  1. List<int> data, {
  2. SocketInfo? destination,
})

Sends data to the given destination.

Being UDP, this function does not wait for a response or even confirmation of a successful send and is therefore very quick and non-blocking.

Implementation

void send(List<int> data, {SocketInfo? destination}) {
  final target = destination ?? this.destination;
  if (target == null) return;
  if (_socket == null) throw StateError("Cannot use a UdpSocket on port $_port after it's been disposed");
  _socket!.send(data, target.address, target.port);
}