How to check send and recv buffer sizes of tokio::net::TcpStream?

In some of the old versions of Tokio, TcpStream offered methods to check the buffer sizes and other socket options. How to do that with Tokio 1.x?

These methods are available on the tokio::net::TcpSocket type.

For things that are missing, use the socket2 crate.

Sure, I know this. But how to get TcpSocket reference from an existing TcpConnection that I got from a listener (incoming connection)? For outgoing it is easy because I can create the socket first and then connect.

Use socket2.