connect method
Connects the stream to a remote endpoint
Implementation
Future<void> connect(
UDPSocket socket,
int remoteId,
int port,
String host,
) async {
if (_connected) throw StateError('Stream is already connected');
if (socket.closing) throw StateError('Socket is closing');
_socket = socket;
this.remoteId = remoteId;
this.remoteHost = host;
this.remotePort = port;
this.remoteFamily = UDX.getAddressFamily(host);
_connected = true;
connectedAt = DateTime.now();
socket.registerStream(this);
_remoteConnectionWindowUpdateSubscription?.cancel();
_remoteConnectionWindowUpdateSubscription = _socket!.on('remoteConnectionWindowUpdate').listen(_handleRemoteConnectionWindowUpdate);
emit('connect');
}