Open NyxCode opened 4 years ago
@yoshuawuyts Correct me if I'm wrong but one of the changes suggested by @NyxCode above would need to be implemented to apply either of the solutions suggested in https://github.com/http-rs/async-h1/issues/74
I'm making a simple proxy server. So being able to read/write a TlsStream
in 2 separate threads is a must.
If people are still interested in this, there's a unsafe work-around:
TlsStream
, and call it reader
.ptr::read()
to make a copy of reader
, name it writer
.ManuallyDrop
to wrap both reader
and writer
.ManuallyDrop::drop()
on one (and only one) of them.Tests worked for me. My code is not in production yet. But this is the only hack for me. I hope this helps someone else.
In long term, I hope crate authors could provide some split()
function, which splits a TlsStream
into 2 parts: one readable-only, one writable-only. I'm sorry that I don't have much knowledge about underlying TLS limits, but I hope that can be safely implemented. As I understand this: those 2 parts do not conflict.
--- Edited ---
I'm sorry it didn't work.
async_std::net::TcpStream
implementsClone
, which makes it possible to read and write to a socket at the same time. Official async-std example This library does not implementClone
forTlsStream
, neither does it implementAsyncRead
orAsyncWrite
for&TlsStream
. How would I rewrite the example above to use TLS whenTlsStream
is not clonable?