Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TcpSocket::from_std #3734

Closed
Darksonn opened this issue Apr 29, 2021 · 2 comments · Fixed by #3838
Closed

TcpSocket::from_std #3734

Darksonn opened this issue Apr 29, 2021 · 2 comments · Fixed by #3838
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-net Module: tokio/net

Comments

@Darksonn
Copy link
Contributor

Currently the only way to convert a socket2 socket into a TcpSocket is the platform-dependent FromRawFd or FromRawSocket methods. Can we do better?

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-net Module: tokio/net C-feature-request Category: A feature request. labels Apr 29, 2021
@aym-v
Copy link

aym-v commented May 12, 2021

I guess one way to approach this would be to implement From<socket2::Socket>

This could raise concerns about depending on transitive dependencies as expressed in: tokio-rs/mio#1431 (comment)

@Darksonn
Copy link
Contributor Author

I mean, we should probably just have a from_std method. We definitely don't want socket2 in our public API.

AtulJatia added a commit to AtulJatia/tokio that referenced this issue Jun 5, 2021
This converts the TcpStream into the platform
specific raw_fd(unix) / raw_socket(windows)
and then converts them into the TcpSocket
as TcpSocket implements the FromRawFd(unix) and
FromRawSocket(windows) traits.

Fixes: tokio-rs#3734
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-net Module: tokio/net
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants