Skip to content

[PR #10962/84decfe5 backport][3.12] add example of setting network interface in custom socket creation #10966

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/10962.feature.rst
13 changes: 13 additions & 0 deletions docs/client_advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,19 @@ make all sockets respect 9*7200 = 18 hours::
return sock
conn = aiohttp.TCPConnector(socket_factory=socket_factory)

``socket_factory`` may also be used for binding to the specific network
interface on supported platforms::

def socket_factory(addr_info):
family, type_, proto, _, _ = addr_info
sock = socket.socket(family=family, type=type_, proto=proto)
sock.setsockopt(
socket.SOL_SOCKET, socket.SO_BINDTODEVICE, b'eth0'
)
return sock

conn = aiohttp.TCPConnector(socket_factory=socket_factory)


Named pipes in Windows
^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Loading