Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
782 views
in Technique[技术] by (71.8m points)

asynchronous - How to await connections to socket and convert them into a FusedStream in Rust

I have a loop {} around a futures::select!. I'd like to

  1. await new connections on a Unix socket.
  2. 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...