Greetings!I'm working with aiocoap, which uses the AI_V4MAPPED flag to use IPv4-mapped addresses for dual-stack support. When trying to run on Windows, creating a
connection fails, because the socket option IPV6_V6ONLY is set to true per default on Windows, whereas the value is configurable on Linux. I've attached a file that should reproduce the error.
A possible fix would be calling socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, False) when V4-mapped addresses have been requested (this bug can also appear on Linux when /proc/sys/net/ipv6/bindv6only contains 1). If you require any more information, feel free to contact me! Best Regards, Jan SeegerPS: I am not a subscriber of this list, so please leave my address on any
replies you send.
import asyncio import socket class TestProtocol(asyncio.Protocol): def __init__(self, con_lost_fut): self.con_lost_fut = con_lost_fut def connection_made(self, transport): print(f"Connection made to {transport}.") transport.write(b"GET /index.html\r\n\r\n") def data_received(self, data: bytes): print(f"Data received: {data}") def connection_lost(self, exc): self.con_lost_fut.set_result(True) print(f"Server closed the connection. Argument: {exc}") async def main(): on_con_lost = asyncio.Future() transport, protocol = await asyncio.get_event_loop().create_connection( lambda: TestProtocol(on_con_lost), family=socket.AF_INET6, flags=socket.AI_V4MAPPED, # neverssl.com host='143.204.208.49', port=80) try: await on_con_lost finally: transport.close() if __name__ == '__main__': asyncio.run(main())
_______________________________________________ Async-sig mailing list Async-sig@python.org https://mail.python.org/mailman/listinfo/async-sig Code of Conduct: https://www.python.org/psf/codeofconduct/