Constructing TcpListener from std::net::TcpListener for fine-grained socket control in glommio async runtime

I’d like to be able to create a glommio::net::TcpListener directly from a pre-configured std::net::TcpListener (or socket2::Socket) to set options like SO_REUSEPORT and other low-level socket parameters. Currently, from_raw_fd works, but it requires unsafe code.

It would be helpful to have a safe, ergonomic API for constructing a Glommio listener from an existing standard listener to enable fine-grained socket configuration.

Is there already such api?

Doesn't look like it.

Wouldn’t this be a rather trivial use case? I suppose it might be worth submitting a PR for it.

On a related note, @alice, how efficiently can we implement a thread-per-core model in Tokio? I’ve attempted to do so by spawning n threads and running a current_thread runtime inside each one. As I’m relatively new to async Rust, are there any potential pitfalls I should be aware of, or is this approach generally not how Tokio is intended to be used?

You could try to submit a PR for the new traits for converting to/from OwnedFd and similar.

Most of the time, work stealing is superior to thread-per-core. But yes, you can get it with multiple runtimes. I believe actix-rt does that.

I am currently working on a shared-nothing architecture. Since work stealing is not applicable in this context, I have been reconsidering the use of Tokio as the asynchronous runtime.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.