python-trio / python-trio/trio

Discussion: should there be a way to set early socket options in the high-level interface?

Open
#281 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

asyncio feature parity design discussion polish
Dominant language
Python
Stars
7.3k
Forks
431
Avg merge
2d 17h
Merged PRs (30d)
6

Description

Specifically, should there be a way to issue arbitrary setsockopt calls in open_tcp_stream and open_tcp_listeners, before the socket is bound by calling connect or bind?

For example, you might want to set SO_REUSEPORT.

The argument against would be that this makes the API more complicated for an obscure and rarely used feature that's better handled by dropping down to the socket layer.

OTOH the high-level API has some actual value in it; dropping down to the socket layer while replicated its functionality is not trivial.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the high-level open_tcp_stream and open_tcp_listeners interfaces and the underlying socket-layer path they wrap. Investigate how setsockopt, including SO_REUSEPORT, would need to be exposed before connect or bind. Done means reaching a clear API decision and documenting or implementing the agreed behavior, with validation for both entry points.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.