aboutsummaryrefslogtreecommitdiff
path: root/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'client.py')
-rw-r--r--client.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/client.py b/client.py
index 4249bcd..2b740cd 100644
--- a/client.py
+++ b/client.py
@@ -1,8 +1,28 @@
+from http.client import HTTPConnection
import os
+import socket
import sys
import xmlrpc.client
-proxy = xmlrpc.client.ServerProxy(f"http://localhost:{os.environ.get("PORT", 8000)}")
+
+class UnixStreamHTTPConnection(HTTPConnection):
+ def connect(self):
+ self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ self.sock.connect(self.host)
+
+
+class UnixStreamTransport(xmlrpc.client.Transport, object):
+ def __init__(self, socket_path):
+ self.socket_path = socket_path
+ super().__init__()
+
+ def make_connection(self, host):
+ return UnixStreamHTTPConnection(self.socket_path)
+
+
+proxy = xmlrpc.client.ServerProxy(
+ "http://localhost", transport=UnixStreamTransport("search.sock")
+)
res = proxy.search(sys.argv[1], sys.argv[2])
print("\n".join(res))