Exemple #1
0
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;
    }
}
Exemple #2
0
void
QuasarSocket::send(const QString& type, const QStringList& args)
{
    if (type.isEmpty()) return;

    TclObject list;
    list.lappend(type);
    for (unsigned int i = 0; i < args.size(); ++i)
	list.lappend(args[i]);

    QString message = list.toString();
    if (message.contains('\n'))
	message = "\002" + message + "\003";
    else
	message += "\n";

    writeBlock(message.utf8(), strlen(message.utf8()));
    flush();
}