--- a/Debugger/DebuggerInterfacePython.py Thu Nov 09 18:31:34 2017 +0100 +++ b/Debugger/DebuggerInterfacePython.py Sat Nov 11 18:44:04 2017 +0100 @@ -407,7 +407,7 @@ """ # Send commands that were waiting for the connection. for cmd in self.queue: - self.qsock.write(cmd.encode('utf8', 'backslashreplace')) + self.__writeJsonCommandToSocket(cmd) self.queue = [] @@ -1105,9 +1105,21 @@ } cmd = json.dumps(commandDict) + '\n' if self.qsock is not None: - self.qsock.write(cmd.encode('utf8', 'backslashreplace')) + self.__writeJsonCommandToSocket(cmd) else: self.queue.append(cmd) + + def __writeJsonCommandToSocket(self, cmd): + """ + Private method to write a JSON command to the socket. + + @param cmd JSON command to be sent + @type str + """ + data = cmd.encode('utf8', 'backslashreplace') + length = "{0:09d}".format(len(data)) + self.qsock.write(length.encode() + data) + self.qsock.flush() def createDebuggerInterfacePython2(debugServer, passive):