Multiple "Tokio:: spawn" using the same "TcpStream" variable #6349
Unanswered
yunfengwangluo
asked this question in
General
Replies: 1 comment
-
I suggest one of the following solutions:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am using "Tokio:: net:: TcpStream". When I try to use the same TcpStream in different functions simultaneously, ownership issues naturally arise. I tried Arc<Mutex, but doing so alone won't solve my problem. When I use the library std:: net: TcpStream or net2, there is a "try_clone" method that can be called. I checked the code of tokio:: net and found that the net used by tokio mainly relies on the "mio:: net" library. I don't know what advantages this library has compared to std:: net. But currently, I am unable to implement my requirements in multiple functions because I need to communicate with other interfaces. I want my code to implement two functions, one to read data and the other to write data.
Please forgive my expression skills, I am very sorry!
If you have free time, please help me solve my problem. Thank you very much!
Beta Was this translation helpful? Give feedback.
All reactions