Skip to content
Open
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
4 changes: 4 additions & 0 deletions tests/test_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ def test_getaddrinfo_22(self):
self._test_getaddrinfo(payload, 80)
self._test_getaddrinfo(payload, 80, type=socket.SOCK_STREAM)

def test_getaddrinfo_broadcast(self):
self._test_getaddrinfo('<broadcast>', 80)
self._test_getaddrinfo('<broadcast>', 80, type=socket.SOCK_STREAM)

######

def test_getnameinfo_1(self):
Expand Down
16 changes: 16 additions & 0 deletions tests/test_udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,22 @@ def test_udp_sendto_dns(self):
s_transport.close()
self.loop.run_until_complete(asyncio.sleep(0.01))

def test_udp_sendto_broadcast(self):
coro = self.loop.create_datagram_endpoint(
asyncio.DatagramProtocol,
local_addr=('127.0.0.1', 0),
family=socket.AF_INET)

s_transport, server = self.loop.run_until_complete(coro)

try:
s_transport.sendto(b'aaaa', ('<broadcast>', 80))
except ValueError as exc:
raise AssertionError('sendto raises {}.'.format(exc))

s_transport.close()
self.loop.run_until_complete(asyncio.sleep(0.01))

def test_send_after_close(self):
coro = self.loop.create_datagram_endpoint(
asyncio.DatagramProtocol,
Expand Down
4 changes: 4 additions & 0 deletions uvloop/handles/udp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ cdef class UDPTransport(UVBaseTransport):
if addr is None:
saddr = NULL
else:
# resolve special hostname <broadcast> to the broadcast address before use
if self._family == uv.AF_INET and addr[0] == '<broadcast>':
addr = (b'255.255.255.255', addr[1])

try:
__convert_pyaddr_to_sockaddr(self._family, addr,
<system.sockaddr*>&saddr_st)
Expand Down
Loading