I have a loop {}
around a futures::select!
. I'd like to
- await new connections on a Unix socket.
- await a new message on one of the Unix streams created in 1. (preferably with some kind of uuid(sent by the connecting client in 1. directly after connecting) attached to it)
I still haven't understood the concept of a Stream correctly, especially futures-rs's "FusedFuture". I tried to create the streams I need using tokio's async-stream, but that didn't work as it does not implement futures-rs's FusedFuture (which I require, as I check other streams in the same select! that benefit/require FusedFutures is_terminated() method)
I think something like tokio_stream::StreamMap is interesting (the key as uuid and the value as a Stream that contains a tupel with the message received on the socket and reference to the UnixStream in order to write back.
I'm really sorry that I cannot provide any examples or something similar to make the issue less unclear. I've tried a lot but I was unable to come any closer to my goal. I hope the way a wrote this is somewhat understandable ??
Whether to use a std::os::unix::net::UnixListener
or tokio::net::UnixListener
is up in the air. I've tried both but was unable to achieve anything with either of them.
question from:
https://stackoverflow.com/questions/65836877/how-to-await-connections-to-socket-and-convert-them-into-a-fusedstream-in-rust 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…