void send(QSocketDevice& socket, const QString& type, const QStringList& args, bool debug) { TclObject list; list.lappend(type); for (unsigned int i = 0; i < args.size(); ++i) list.lappend(args[i]); if (debug) logDebug("send: " + list.toString()); QString message = list.toString(); if (message.contains('\n')) message = "\002" + message + "\003"; else message += "\n"; QCString data = message.utf8(); int len = data.length(); int pos = 0; while (pos < len) { int count = socket.writeBlock(data.data() + pos, len - pos); socket.flush(); if (count == -1) { logError("writeBlock error: %d", errno); exit(4); } pos += count; } }