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

add the ability to wrap stdlib sockets #845

Open
1 task done
graingert opened this issue Dec 22, 2024 · 0 comments · May be fixed by #878
Open
1 task done

add the ability to wrap stdlib sockets #845

graingert opened this issue Dec 22, 2024 · 0 comments · May be fixed by #878
Labels
enhancement New feature or request

Comments

@graingert
Copy link
Collaborator

graingert commented Dec 22, 2024

Things to check first

  • I have searched the existing issues and didn't find my feature already requested there

Feature description

I'd like the ability to wrap a stdlib socket in a SocketStream/UNIXSocketStream/SocketListener/UDPSocket/ConnectedUDPSocket

Ideally it would be a synchronous function that takes a connected or listening socket of any kind and does the right thing, but asyncio only provides async methods to adopt a socket. It's also hard to detect if a socket is connected or connecting or listening securely for the purposes of wrapping with TLS

Perhaps the best interface for now would be two async functions, async def wrap_client_sock -> SocketStream | UNIXSocketStream | ConnectedUDPSocket and async def wrap_server_sock -> SocketListener | UDPSocket ?

Use case

I plan to use it with socket.socketpair in the anyio.to_process.run_sync implementation to fix #516

@graingert graingert added the enhancement New feature or request label Dec 22, 2024
leon1995 added a commit to leon1995/anyio that referenced this issue Feb 24, 2025
@leon1995 leon1995 linked a pull request Feb 24, 2025 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant