[issue35302] create_connection with local_addr misses valid socket bindings

Ronald Oussoren report at bugs.python.org
Wed Dec 19 11:12:53 EST 2018


Ronald Oussoren <ronaldoussoren at mac.com> added the comment:

A better workaround is IMHO to force the socket to be IPV6 only:

sd = socket.socket(socket.AF_INET6, socket.SOCK_STREAM, 0)
sd.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)

That avoids the ordering problem as well as having to try all possible combinations of source and destination addreses.

I've tested that setting this option makes it impossible to bind a IPv6 socket to an IPv4 address.  This is on macOS 10.14.2, I haven't checked other versions of macOS.

----------
nosy: +ronaldoussoren

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35302>
_______________________________________


More information about the Python-bugs-list mailing list