That's a nice problem. As far as I know, the Rust standard library doesn't have a way to create a TcpStream that wraps an existing raw file descriptor. You can only get a raw file descriptor via FFI anyway, so that's fine for most programs.<p>A TcpStream is just a struct containing the file descriptor (<a href="https://github.com/rust-lang/rust/blob/master/src/libstd/sys_common/net.rs#L207-L209" rel="nofollow">https://github.com/rust-lang/rust/blob/master/src/libstd/sys...</a>) and nothing else, so this would be fine:<p><pre><code> let stream: std::net::TcpStream = unsafe { std::mem::transmute(socket) };</code></pre>