Implement UDP socket support and related transport management in the event loop #46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds full support for UDP (datagram) transports to the event loop, including both the Python and Rust sides. It implements UDP socket creation, management, event dispatch, and exposes a
UDPTransportclass to Python. The changes also include comprehensive tests for UDP endpoint creation, both with new and existing sockets, and for various address families.The most important changes are:
UDP Transport Implementation:
UDPTransportclass insrc/udp.rs, including methods for sending and receiving datagrams, handling protocol callbacks, and managing socket state. Also introduced aUDPHandlefor event processing._udp_connfunction inEventLoopto create and register UDP transports, handling socket setup and protocol attachment.EventLoop(udp_socket_add,udp_socket_rem,udp_socket_close,get_udp_transport) and audp_transportsmap to track active UDP transports. [1] [2] [3]Event Loop Integration:
IOHandleenum and event dispatch logic to support UDP sockets, including a handler for readable UDP events. [1] [2] [3]src/lib.rsfor inclusion in the Python extension.Python API and Testing:
create_datagram_endpointinrloop/loop.pyto support creating UDP endpoints with various socket/address options, including error handling and socket configuration.tests/udp/test_udp.py, covering creation with existing sockets, UNIX sockets, and both local and remote addresses. [1] [2]