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?


net2’s TcpBuilder can probably help:


Is there anything similar in Tokio?


You can create a tokio tcpstream from a std::net one: