meh / rust-tun

TUN device creation and handling.
340 stars 133 forks source link

Help with multithreading, read and write. #80

Open yunfengwangluo opened 7 months ago

yunfengwangluo commented 7 months ago

First of all, thank you for using your valuable experience to see my request! I want to use two threads to handle reads and writes separately, but I haven't found any good methods other than using read write locks. The read write lock, due to its ability to block, has not yet achieved the goal of simultaneously reading and writing separately. Is there any solution?

szguoxz commented 6 months ago

This could be achieved by tokio::select(readfuture, writechannelrecvfuture), but the solution sucks. Ultimately, I believe the tun driver needs to address this. this is such a big problem, I am surprised it's not addressed from day one.

szguoxz commented 6 months ago

I found a way to achieve this: dev.into_framed().split()