-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Setting client TCP socket options before connection #10520
Description
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