Add support for unix sockets and improve rpc testing

This commit is contained in:
Jason Paryani
2015-04-13 16:51:38 -07:00
parent 36d3bdcd6b
commit 3d77722e88
2 changed files with 39 additions and 6 deletions

View File

@@ -2204,13 +2204,18 @@ cdef class TwoPartyClient:
del self.thisptr
cpdef _connect(self, host_string):
host, port = host_string.split(':')
if host_string.startswith('unix:'):
path = host_string[5:]
sock = _socket.socket(_socket.AF_UNIX, _socket.SOCK_STREAM)
sock.connect(path)
else:
host, port = host_string.split(':')
sock = _socket.create_connection((host, port))
sock = _socket.create_connection((host, port))
# Set TCP_NODELAY on socket to disable Nagle's algorithm. This is not
# neccessary, but it speeds things up.
sock.setsockopt(_socket.IPPROTO_TCP, _socket.TCP_NODELAY, 1)
# Set TCP_NODELAY on socket to disable Nagle's algorithm. This is not
# neccessary, but it speeds things up.
sock.setsockopt(_socket.IPPROTO_TCP, _socket.TCP_NODELAY, 1)
return sock
cpdef restore(self, objectId) except +reraise_kj_exception: