I'm working on a project where I need to implement reliable UDP
in Python using socket. The goal is to create a class similar to socket.socket
where the user can use methods such as connect(addr)
, accept()
, close()
, send(data)
, and recv(size)
just like TCP
, but on top of UDP
.
Here are my questions:
How can I efficiently implement reliable UDP
with ordering of packets and ack for packets with window size for unacked packets?
How can I implement a buffer to store incoming messages and serve the recv()
method? I tried using bytearray and bytes, but they are very slow for large data.
Should I use threading
to constantly listen for incoming messages and push them to the buffer while sending back acks?
Any guidance on these questions would be greatly appreciated. Thank you in advance!
- Currently I tried to implement it with receiving thread which constantly tries to read new message and if it's ack it's update the unacked packets, if it's data it pushes it to bytearray