Running code on the RawFd before connecting a TcpStream?

I'm experimenting with Android VpnService.
Any outgoing socket connection needs to be protected by calling a Java method with the socket fd passed in before connecting, but our TcpStream immediately connects to the server.
Is there any way to achieve this?

1 Like

net2's TcpBuilder can probably help: https://doc.rust-lang.org/net2-rs/net2/struct.TcpBuilder.html

1 Like

Is there anything similar in Tokio?

1 Like

You can create a tokio tcpstream from a std::net one: tokio_core::net::TcpStream - Rust.

1 Like