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

Setting client TCP socket options before connection #10520

Open
1 task done
kjander0 opened this issue Mar 6, 2025 · 2 comments
Open
1 task done

Setting client TCP socket options before connection #10520

kjander0 opened this issue Mar 6, 2025 · 2 comments
Milestone

Comments

@kjander0
Copy link

kjander0 commented Mar 6, 2025

Is your feature request related to a problem?

I would like to have socket options applied before a connection is made so that they apply to handshake packets (e.g. IP_TOS, IPv6_TCLASS ).

Describe the solution you'd like

aiohappyeyeballs v2.5.0 now receives a "socket_factory" parameter (callback that returns a new socket) that allows a user to perform their own socket creation before each connection.
aio-libs/aiohappyeyeballs@v2.4.8...v2.5.0

I would like TCPConnector's constructor to offer a similar optional parameter so this functionality can be used. I propose that a "socket_factory" parameter replaces the recent "tcp_sockopts" parameter.

Describe alternatives you've considered

The existing tcp_sockopts could be repurposed for this, however, passing in socket options like this doesn't allow one to set different options depending on the destination address (e.g., IPv4 vs IPv6).

Related component

Client

Additional context

I worked the related PR for aiohappyeyeballs and am happy to offer a PR for this change too.

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
@Dreamsorcerer
Copy link
Member

@bdraco Should we do the same here, replacing #10474? It's not released yet, so it can still be changed.

@Dreamsorcerer Dreamsorcerer added this to the 3.12 milestone Mar 6, 2025
@bdraco
Copy link
Member

bdraco commented Mar 6, 2025

I think it makes sense to use the same pattern here.

TimMenninger added a commit to TimMenninger/aiohttp that referenced this issue Mar 10, 2025
Instead of TCPConnector taking a list of sockopts to be applied sockets
created, take a socket_factory callback that allows the caller to
implement socket creation entirely.
TimMenninger added a commit to TimMenninger/aiohttp that referenced this issue Mar 10, 2025
Instead of TCPConnector taking a list of sockopts to be applied sockets
created, take a socket_factory callback that allows the caller to
implement socket creation entirely.
TimMenninger added a commit to TimMenninger/aiohttp that referenced this issue Mar 10, 2025
Instead of TCPConnector taking a list of sockopts to be applied sockets
created, take a socket_factory callback that allows the caller to
implement socket creation entirely.
TimMenninger added a commit to TimMenninger/aiohttp that referenced this issue Mar 10, 2025
Instead of TCPConnector taking a list of sockopts to be applied sockets
created, take a socket_factory callback that allows the caller to
implement socket creation entirely.
TimMenninger added a commit to TimMenninger/aiohttp that referenced this issue Mar 10, 2025
Instead of TCPConnector taking a list of sockopts to be applied sockets
created, take a socket_factory callback that allows the caller to
implement socket creation entirely.
TimMenninger added a commit to TimMenninger/aiohttp that referenced this issue Mar 10, 2025
Instead of TCPConnector taking a list of sockopts to be applied sockets
created, take a socket_factory callback that allows the caller to
implement socket creation entirely.
TimMenninger added a commit to TimMenninger/aiohttp that referenced this issue Mar 10, 2025
Instead of TCPConnector taking a list of sockopts to be applied sockets
created, take a socket_factory callback that allows the caller to
implement socket creation entirely.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants