Ejemplo n.º 1
0
void SocketTestWindow::on_m_pbConnect_clicked()
{
    QString ip = ui->m_leAddress->text();
    quint16 port = ui->m_lePort->text().toInt();
    m_tcpEnable = ui->m_rbTcpEnable->isChecked();
    m_udpEnable = !m_tcpEnable;
    if(m_tcpEnable)
    {
        m_socketClient = new QTcpSocket();
        m_socketClient->connectToHost(ip,port);
        connect(m_socketClient,SIGNAL(connected()),SLOT(connectedToHost()));
    }
    else
    {
        m_socketClient = new QUdpSocket();
        m_remoteHost = ip;
        m_remotePort = port;
        m_socketClient->connectToHost(m_remoteHost,m_remotePort);
        connect(m_socketClient, SIGNAL(readyRead()),
                     this, SLOT(readyReadMessage()));
        ui->m_pbConnect->setEnabled(false);
        ui->m_pbListen->setEnabled(false);
        ui->m_rbUdpEnable->setEnabled(false);
        ui->m_rbTcpEnable->setEnabled(false);
        ui->m_pbDisconnect->setEnabled(true);
        m_startFlags = true;
    }
    m_isServer = false;

}
QJsonPipe::QJsonPipe(QObject *parent)
    : QObject(parent)
    , d_ptr(new QJsonPipePrivate())
{
    Q_D(QJsonPipe);
    d->mInBuffer = new QJsonBuffer(this);
    connect(d->mInBuffer, SIGNAL(readyReadMessage()), SLOT(processMessages()));
}
Ejemplo n.º 3
0
void SocketTestWindow::connectedToHost()
{
    connect(m_socketClient, SIGNAL(readyRead()),
                 this, SLOT(readyReadMessage()));
    connect(m_socketClient,SIGNAL(disconnected()),this,SLOT(disConnected()));
    ui->m_pbConnect->setEnabled(false);
    ui->m_pbListen->setEnabled(false);
    ui->m_rbUdpEnable->setEnabled(false);
    ui->m_rbTcpEnable->setEnabled(false);
    ui->m_pbDisconnect->setEnabled(true);
    m_startFlags = true;
}