QByteArray ba;
ba.append(LOGIN);
ba.append(ui->lusername->text().toLatin1().length());
ba.append(ui->lusername->text().toLatin1());
ba.append(ui->lpasswd->text().toLatin1().length());
ba.append(ui->lpasswd->text().toLatin1());
qDebug()< socket->write(ba);
上面是我自己定义的一个协议,协议是这样的:
LOGIN+用户名长度+用户名+密码长度+密码
这是在客户端,想通过tcp利用socket把信息发送到服务端,直接这样write(ba)为什么不行呢。