From 64866a0f4954c6df767a233c07ab5f2f7fb93dc2 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 20 Nov 2014 14:21:41 -0800 Subject: [PATCH] pc_rpc: add init magic string --- artiq/management/pc_rpc.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/artiq/management/pc_rpc.py b/artiq/management/pc_rpc.py index e8bf65c77..e712a7a8b 100644 --- a/artiq/management/pc_rpc.py +++ b/artiq/management/pc_rpc.py @@ -29,6 +29,9 @@ class IncompatibleServer(Exception): pass +_init_string = b"ARTIQ pc_rpc\n" + + class Client: """This class proxies the methods available on the server so that they can be used as if they were local methods. @@ -59,6 +62,7 @@ class Client: """ def __init__(self, host, port, expected_id_type): self.socket = socket.create_connection((host, port)) + self.socket.sendall(_init_string) self._identify(expected_id_type) def get_rpc_id(self): @@ -176,6 +180,9 @@ class Server: @asyncio.coroutine def _handle_connection_task(self, reader, writer): try: + line = yield from reader.readline() + if line != _init_string: + return while True: line = yield from reader.readline() if not line: