Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@DVNghiem
Copy link
Contributor

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 UDPTransport class 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:

  • Added a new UDPTransport class in src/udp.rs, including methods for sending and receiving datagrams, handling protocol callbacks, and managing socket state. Also introduced a UDPHandle for event processing.
  • Implemented the _udp_conn function in EventLoop to create and register UDP transports, handling socket setup and protocol attachment.
  • Added UDP socket management methods to EventLoop (udp_socket_add, udp_socket_rem, udp_socket_close, get_udp_transport) and a udp_transports map to track active UDP transports. [1] [2] [3]

Event Loop Integration:

  • Extended the IOHandle enum and event dispatch logic to support UDP sockets, including a handler for readable UDP events. [1] [2] [3]
  • Registered the new UDP module in src/lib.rs for inclusion in the Python extension.

Python API and Testing:

  • Implemented create_datagram_endpoint in rloop/loop.py to support creating UDP endpoints with various socket/address options, including error handling and socket configuration.
  • Added and enabled comprehensive UDP tests in tests/udp/test_udp.py, covering creation with existing sockets, UNIX sockets, and both local and remote addresses. [1] [2]

@gi0baro gi0baro linked an issue Sep 3, 2025 that may be closed by this pull request
@gi0baro gi0baro merged commit f72899c into gi0baro:master Sep 10, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UDP support

2 participants