1
1
# cython: language_level=3, embedsignature=True
2
2
3
-
3
+ import asyncio
4
4
cimport cython
5
5
6
6
from .includes.debug cimport UVLOOP_DEBUG
@@ -38,10 +38,6 @@ include "includes/stdlib.pxi"
38
38
include " errors.pyx"
39
39
40
40
41
- cdef _is_sock_ip(sock_family):
42
- return sock_family == uv.AF_INET or sock_family == uv.AF_INET6
43
-
44
-
45
41
cdef _is_sock_stream(sock_type):
46
42
# Linux's socket.type is a bitmask that can include extra info
47
43
# about socket, therefore we can't do simple
@@ -1298,7 +1294,16 @@ cdef class Loop:
1298
1294
cdef:
1299
1295
TCPServer tcp
1300
1296
system.addrinfo * addrinfo
1301
- Server server = Server(self )
1297
+ Server server
1298
+
1299
+ if sock is not None and sock.family == uv.AF_UNIX:
1300
+ if host is not None or port is not None :
1301
+ raise ValueError (
1302
+ ' host/port and sock can not be specified at the same time' )
1303
+ return await self .create_unix_server(
1304
+ protocol_factory, sock = sock, ssl = ssl)
1305
+
1306
+ server = Server(self )
1302
1307
1303
1308
if ssl is not None and not isinstance (ssl, ssl_SSLContext):
1304
1309
raise TypeError (' ssl argument must be an SSLContext or None' )
@@ -1349,10 +1354,10 @@ cdef class Loop:
1349
1354
else :
1350
1355
if sock is None :
1351
1356
raise ValueError (' Neither host/port nor sock were specified' )
1352
- if (not _is_sock_stream(sock.type) or
1353
- not _is_sock_ip(sock.family)):
1357
+ if not _is_sock_stream(sock.type):
1354
1358
raise ValueError (
1355
- ' A TCP Stream Socket was expected, got {!r}' .format(sock))
1359
+ ' A Stream Socket was expected, got {!r}' .format(sock))
1360
+
1356
1361
tcp = TCPServer.new(self , protocol_factory, server, ssl,
1357
1362
uv.AF_UNSPEC)
1358
1363
@@ -1404,6 +1409,14 @@ cdef class Loop:
1404
1409
object protocol
1405
1410
object ssl_waiter
1406
1411
1412
+ if sock is not None and sock.family == uv.AF_UNIX:
1413
+ if host is not None or port is not None :
1414
+ raise ValueError (
1415
+ ' host/port and sock can not be specified at the same time' )
1416
+ return await self .create_unix_connection(
1417
+ protocol_factory, None ,
1418
+ sock = sock, ssl = ssl, server_hostname = server_hostname)
1419
+
1407
1420
app_protocol = protocol = protocol_factory()
1408
1421
ssl_waiter = None
1409
1422
if ssl:
@@ -1423,6 +1436,10 @@ cdef class Loop:
1423
1436
raise ValueError (' server_hostname is only meaningful with ssl' )
1424
1437
1425
1438
if host is not None or port is not None :
1439
+ if sock is not None :
1440
+ raise ValueError (
1441
+ ' host/port and sock can not be specified at the same time' )
1442
+
1426
1443
fs = []
1427
1444
f1 = f2 = None
1428
1445
@@ -1536,10 +1553,9 @@ cdef class Loop:
1536
1553
if sock is None :
1537
1554
raise ValueError (
1538
1555
' host and port was not specified and no sock specified' )
1539
- if (not _is_sock_stream(sock.type) or
1540
- not _is_sock_ip(sock.family)):
1556
+ if not _is_sock_stream(sock.type):
1541
1557
raise ValueError (
1542
- ' A TCP Stream Socket was expected, got {!r}' .format(sock))
1558
+ ' A Stream Socket was expected, got {!r}' .format(sock))
1543
1559
1544
1560
waiter = self ._new_future()
1545
1561
tr = TCPTransport.new(self , protocol, None , waiter)
0 commit comments