Skip to content

Commit

Permalink
pc_rpc: add init magic string
Browse files Browse the repository at this point in the history
sbourdeauducq committed Nov 20, 2014
1 parent 914bdd9 commit 64866a0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions artiq/management/pc_rpc.py
Original file line number Diff line number Diff line change
@@ -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 @@ def _handle_connection(self, reader, writer):
@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:

0 comments on commit 64866a0

Please sign in to comment.