diff --git a/sargraph.py b/sargraph.py index cec6e1c..71058a0 100755 --- a/sargraph.py +++ b/sargraph.py @@ -34,7 +34,7 @@ def send(session: str, message: str): if not file_exists(socket_path): fail(f"Session '{session}' does not exist") - sock = watch.get_bound_socket(socket_path) + sock = watch.get_socket() sock.connect(socket_path) sock.send(message.encode("utf-8")) sock.close() diff --git a/watch.py b/watch.py index 9529faf..4d6453b 100644 --- a/watch.py +++ b/watch.py @@ -104,8 +104,11 @@ def read_iface_stats(iface): def get_socket_path(session): return fr"\\.\pipe\sargraph-{session}" if is_windows() else f"/tmp/sargraph-{session}.sock" +def get_socket(): + return socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) + def get_bound_socket(sock_path): - sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) + sock = get_socket() sock.bind(sock_path) return sock