void Connection::onConnected() {
    // stop trying reconnect if it was alive
    stopReconnecting();

    // abridged version of the protocol requires sending 0xef byte at beginning
    unsigned char byte = 0xef;
    qint32 writtenBytes = writeOut(&byte, 1);
    Q_UNUSED(writtenBytes);
    Q_ASSERT(writtenBytes == 1);

    // process the rest of operations in inherited classes
    processConnected();
}
示例#2
0
文件: clien.cpp 项目: napasa/weary
//通常在构造函数内进行初始化
Clien::Clien(QObject *parent) :
    QObject(parent)
{
    connectedFlag = false;
    isArrive = false;
    nextBlockSize=0;
    connect(&tcpSocket,SIGNAL(connected()),
                     this,SLOT(processConnected()));
    connect(&tcpSocket,SIGNAL(disconnected()),
                     this,SLOT(processDisconnected()));
    connect(&tcpSocket,SIGNAL(error(QAbstractSocket::SocketError)),
                     this,SLOT(processDisconnected()));
    connect(&tcpSocket,SIGNAL(readyRead()),         //数据到达信号触发读取槽
                     this,SLOT(readMessage()));
    //connectHost();
}