[GH-ISSUE #434] After Porting to Tokio, it seems impossible to use net2::UdpBuilder #488

Closed
opened 2026-03-15 22:45:49 +03:00 by kerem · 3 comments
Owner

Originally created by @oherrala on GitHub (Apr 27, 2018).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/434

We need to use net2 crates UdpBuilder for Trust-DNS based DNS server, but with current Git master I can't find a way from going from std::net::UdpSocket to tokio_udp::UdpSocket. There's probably same issue with TCP side.

Related issue: #385.
And pull requests: #427 (UDP), #426 (TCP).

Something like this could work in server/src/server/server_future.rs's ServerFuture:

    pub fn register_socket_std(&self, socket: std::net::UdpSocket) {
        let handle = self.io_loop.handle();
        let sock = tokio_udp::UdpSocket::from_std(socket, &handle)
            .map_err(|e| panic!("error in UDP register_socket_std: {}", e));
    }

for registering std's UdpSocket, but there seems to be two incompatible Tokio Reactors in play here:

error[E0308]: mismatched types
  --> server/src/server/server_future.rs:79:59
   |
79 |         let sock = tokio_udp::UdpSocket::from_std(socket, &handle)
   |                                                           ^^^^^^^ expected struct `tokio_reactor::Handle`, found struct `tokio_core::reactor::Handle`
   |
   |
   = note: expected type `&tokio_reactor::Handle`
              found type `&tokio_core::reactor::Handle`

I'm not too familiar with Tokio, but it looks like Trust-DNS need to change it's Reactor from one version to another to be compatible with tokio-udp?

Originally created by @oherrala on GitHub (Apr 27, 2018). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/434 We need to use [`net2`](https://docs.rs/net2/) crates [`UdpBuilder`](https://docs.rs/net2/0.2.32/net2/struct.UdpBuilder.html) for Trust-DNS based DNS server, but with current Git master I can't find a way from going from `std::net::UdpSocket` to `tokio_udp::UdpSocket`. There's probably same issue with TCP side. Related issue: #385. And pull requests: #427 (UDP), #426 (TCP). Something like this could work in `server/src/server/server_future.rs`'s `ServerFuture`: ```rust pub fn register_socket_std(&self, socket: std::net::UdpSocket) { let handle = self.io_loop.handle(); let sock = tokio_udp::UdpSocket::from_std(socket, &handle) .map_err(|e| panic!("error in UDP register_socket_std: {}", e)); } ``` for registering std's `UdpSocket`, but there seems to be two incompatible Tokio Reactors in play here: ``` error[E0308]: mismatched types --> server/src/server/server_future.rs:79:59 | 79 | let sock = tokio_udp::UdpSocket::from_std(socket, &handle) | ^^^^^^^ expected struct `tokio_reactor::Handle`, found struct `tokio_core::reactor::Handle` | | = note: expected type `&tokio_reactor::Handle` found type `&tokio_core::reactor::Handle` ``` I'm not too familiar with Tokio, but it looks like Trust-DNS need to change it's Reactor from one version to another to be compatible with tokio-udp?
kerem closed this issue 2026-03-15 22:45:54 +03:00
Author
Owner

@bluejekyll commented on GitHub (Apr 27, 2018):

Yes. The libraries are currently in transition from the older tokio libs to the new tokio_* ecosystem. @keruspe is leading the effort there. Not sure if this was missed, or just not done yet.

<!-- gh-comment-id:385006397 --> @bluejekyll commented on GitHub (Apr 27, 2018): Yes. The libraries are currently in transition from the older tokio libs to the new tokio_* ecosystem. @keruspe is leading the effort there. Not sure if this was missed, or just not done yet.
Author
Owner

@Keruspe commented on GitHub (Apr 27, 2018):

@oherrala this needs to be &tokio_reactor::Handle::current() insted or &handle.

Note that all references to any of those Handle implementations in public APIs are disappearing in #433

<!-- gh-comment-id:385007584 --> @Keruspe commented on GitHub (Apr 27, 2018): @oherrala this needs to be `&tokio_reactor::Handle::current()` insted or `&handle`. Note that all references to any of those `Handle` implementations in public APIs are disappearing in #433
Author
Owner

@oherrala commented on GitHub (Apr 30, 2018):

Thanks @Keruspe!

<!-- gh-comment-id:385325223 --> @oherrala commented on GitHub (Apr 30, 2018): Thanks @Keruspe!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#488
No description provided.