diff --git a/tests/test_udp.py b/tests/test_udp.py index 545d595..fe3c4ec 100644 --- a/tests/test_udp.py +++ b/tests/test_udp.py @@ -97,6 +97,24 @@ class _TestUDP: server.transport.close() self.loop.run_until_complete(server.done) + def test_create_datagram_endpoint_ipv6_family(self): + class TestMyDatagramProto(MyDatagramProto): + def __init__(inner_self): + super().__init__(loop=self.loop) + + def datagram_received(self, data, addr): + super().datagram_received(data, addr) + self.transport.sendto(b'resp:' + data, addr) + + coro = self.loop.create_datagram_endpoint( + TestMyDatagramProto, local_addr=None, family=socket.AF_INET6) + s_transport = None + try: + s_transport, server = self.loop.run_until_complete(coro) + finally: + if s_transport: + s_transport.close() + def test_create_datagram_endpoint_sock(self): sock = None local_address = ('127.0.0.1', 0) diff --git a/uvloop/loop.pyx b/uvloop/loop.pyx index be5c8d2..256ef53 100644 --- a/uvloop/loop.pyx +++ b/uvloop/loop.pyx @@ -2433,7 +2433,10 @@ cdef class Loop: self._sock_set_reuseport(udp._fileno()) socket = udp._get_socket() - socket.bind(('0.0.0.0', 0)) + if family == uv.AF_INET6: + socket.bind(('::', 0)) + else: + socket.bind(('0.0.0.0', 0)) else: lai = (lads).data while lai is not NULL: