From 69516136c441a23dd04255694fcae34e45325646 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 4 Apr 2016 19:07:08 +0800 Subject: [PATCH] protocols/pc_rpc: add get_local_host to clients --- artiq/protocols/pc_rpc.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/artiq/protocols/pc_rpc.py b/artiq/protocols/pc_rpc.py index bc19f7c5e..5be798c6d 100644 --- a/artiq/protocols/pc_rpc.py +++ b/artiq/protocols/pc_rpc.py @@ -132,6 +132,10 @@ class Client: identification information of the server.""" return (self.__target_names, self.__description) + def get_local_host(self): + """Returns the address of the local end of the connection.""" + return self.__socket.getsockname()[0] + def close_rpc(self): """Closes the connection to the RPC server. @@ -224,6 +228,10 @@ class AsyncioClient: selected yet.""" return self.__selected_target + def get_local_host(self): + """Returns the address of the local end of the connection.""" + return self.__writer.get_extra_info("socket").getsockname()[0] + def get_rpc_id(self): """Returns a tuple (target_names, description) containing the identification information of the server.""" @@ -396,6 +404,12 @@ class BestEffortClient: return self.__do_rpc(name, args, kwargs) return proxy + def get_selected_target(self): + raise NotImplementedError + + def get_local_host(self): + raise NotImplementedError + def _format_arguments(arguments): fmtargs = []