main function
Implementation
Future<void> main() async {
final socket = await RawDatagramSocket.bind("127.0.0.1", 0);
final quicSession = QuicSession(
Uint8List.fromList(HEX.decode("0001020304050607")),
socket,
);
print("listening ip:${socket.address.address}:${socket.port}");
socket.listen((ev) {
if (ev == RawSocketEvent.read) {
final dg = socket.receive();
if (dg != null) {
// _onPacket(dg);
print("Data datagram received: ${dg.data.length}");
final packetList = splitCoalescedPackets(dg.data);
print(packetList.length);
for (final pkt in packetList) {
_receivingQuicPacket(dg.address, dg.port, pkt);
quicSession.handleQuicPacket(pkt);
}
}
}
});
quicSession.sendClientHello(
address: InternetAddress("127.0.0.1"),
port: 4433,
authority: 'localhost',
);
// Timer.periodic(Duration(seconds: 2), (_) {
// socket.send(udp1ClientHello, InternetAddress("127.0.0.1"), 4433);
// });
}