Skip to content
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
20 changes: 19 additions & 1 deletion tests/test_udp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import asyncio
import os
import socket
import unittest
import sys
import tempfile
import unittest
import uuid

from uvloop import _testbase as tb

Expand Down Expand Up @@ -155,6 +158,21 @@ def test_create_datagram_endpoint_sock(self):
tr.close()
self.loop.run_until_complete(pr.done)

@unittest.skipIf(sys.version_info < (3, 5, 1),
"asyncio in 3.5.0 doesn't have the 'sock' argument")
def test_create_datagram_endpoint_sock_unix_domain(self):
tmp_file = os.path.join(tempfile.gettempdir(), str(uuid.uuid4()))
sock = socket.socket(socket.AF_UNIX, type=socket.SOCK_DGRAM)
sock.bind(tmp_file)

with sock:
f = self.loop.create_datagram_endpoint(
lambda: MyDatagramProto(loop=self.loop), sock=sock)
tr, pr = self.loop.run_until_complete(f)
self.assertIsInstance(pr, MyDatagramProto)
tr.sendto(b'HELLO', tmp_file)
tr.close()
self.loop.run_until_complete(pr.done)

class Test_UV_UDP(_TestUDP, tb.UVTestCase):

Expand Down
4 changes: 3 additions & 1 deletion uvloop/handles/udp.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import socket

cdef class UDPTransport(UVBaseTransport):

def __cinit__(self):
Expand Down Expand Up @@ -141,7 +143,7 @@ cdef class UDPTransport(UVBaseTransport):
raise ValueError(
'Invalid address: must be None or {}'.format(self.address))

if addr is not None:
if addr is not None and self.sock.family != socket.AF_UNIX:
addrinfo = __static_getaddrinfo_pyaddr(
addr[0], addr[1],
uv.AF_UNSPEC, self.sock.type, self.sock.proto, 0)
Expand Down