def Send(self, msg): """Send a message. This just sends a message and doesn't wait for the response. """ if constants.LUXI_EOM in msg: raise errors.ProtocolError("Message terminator found in payload") self._CheckSocket() self._wstream.write(msg + constants.LUXI_EOM) self._wstream.flush()
def Send(self, msg): """Send a message. This just sends a message and doesn't wait for the response. """ if constants.LUXI_EOM in msg: raise errors.ProtocolError("Message terminator found in payload") self._CheckSocket() try: # TODO: sendall is not guaranteed to send everything self.socket.sendall(msg + constants.LUXI_EOM) except socket.timeout as err: raise errors.TimeoutError("Sending timeout: %s" % str(err))
def _CheckSocket(self): """Make sure we are connected. """ if self._rstream is None or self._wstream is None: raise errors.ProtocolError("Connection is closed")