rust icon indicating copy to clipboard operation
rust copied to clipboard

Provide listen() variant that accepts listener

Open Natureshadow opened this issue 1 year ago • 4 comments

In order to use systemd socket activation, it would be good to provide a variant of listen that, instead of an address string, accepts a Listener.

Natureshadow avatar Mar 30 '23 22:03 Natureshadow

Hmm, reading the code, it seems that passed sockets are silently listened on.

Natureshadow avatar Mar 30 '23 23:03 Natureshadow

It works fine, just listen on unix:///proc/self/fd/3.

You can test it using something like: systemd-socket-activate -l /tmp/test.sock -- cargo run bonus points by using idle timeout to exit when not needed 😁

This issue can be closed.

Gunni avatar Jan 26 '24 10:01 Gunni

It works fine, just listen on unix:///proc/self/fd/3.

And to find out that the fd is 3, I use a dice ;)?

Natureshadow avatar Jan 26 '24 10:01 Natureshadow

And to find out that the fd is 3, I use a dice ;)?

It's part of systemd socket activation https://www.freedesktop.org/software/systemd/man/latest/systemd-socket-activate.html

Otherwise, standard input and output will be inherited, and sockets will be passed through file descriptors 3 and higher.

Gunni avatar Jan 26 '24 17:01 Gunni