示例#1
0
void TelnetClient::connectionFailed(QAbstractSocket::SocketError error)
{
    Q_UNUSED(error);
    _status=0;
    qDebug() << "Outgoing connection failed" << _socket->errorString();
    _connection_tries++;
    if(_connection_tries < 2)
    {
        this->connectHost(_hostname,_port);
    }
    else
    {
        emit connectionFailure();
    }

}
示例#2
0
void StreamClient::handleConnect(const boost::system::error_code& error,
                                 tcp::resolver::iterator endpoint_iterator)
{
    if (!error)
    {
        emit connectionSuccess();
        newReadCycle();
    } else if (endpoint_iterator != tcp::resolver::iterator()) {
        m_socket.close();
        tcp::endpoint endpoint = *endpoint_iterator;
        m_socket.async_connect(endpoint,
                              boost::bind(&StreamClient::handleConnect, this,
                                          boost::asio::placeholders::error, ++endpoint_iterator));
    } else {
        m_exit_result = CONNECTION_FAILED;
        m_socket.close();
        emit connectionFailure();
    }
}
示例#3
0
// Accept connection from server and initiate the SSL handshake
void Server::acceptConnection()
{
  QSslSocket *socket = server.nextPendingConnection();
  assert(socket);

  // QSslSocket emits the encrypted() signal after the encrypted connection is established
  connect(socket, SIGNAL(encrypted()), this, SLOT(handshakeComplete()));

  // Report any SSL errors that occur
  connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(sslErrors(const QList<QSslError> &)));

  connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionFailure()));

  socket->setPrivateKey(key);
  socket->setLocalCertificate(certificate);

  socket->setPeerVerifyMode(QSslSocket::VerifyNone);
  socket->startServerEncryption();
}
示例#4
0
void AdminWindow::showAdmin(ConnectionSettings *connection)
{
    // clear ui
    ui->usersList->clear();
    ui->usersList->addItem(tr("Updating..."));
    ui->usersList->setFocus(Qt::OtherFocusReason);

    // establish connection
    m_server = QSharedPointer<Server>(new Server(*connection));
    m_connector = QSharedPointer<Connector>(new Connector(m_server));

    bool success;
    success = connect(m_connector.data(), SIGNAL(failure(Connector::FailureReason)), this, SLOT(connectionFailure(Connector::FailureReason)), Qt::QueuedConnection);
    Q_ASSERT(success);
    success = connect(m_connector.data(), SIGNAL(success()), this, SLOT(connected()));
    Q_ASSERT(success);
    success = connect(m_server.data(), SIGNAL(messageReceived(QSharedPointer<IncomingMessage>)), this, SLOT(processMessage(QSharedPointer<IncomingMessage>)));
    Q_ASSERT(success);
    success = connect(m_server.data(), SIGNAL(socketDisconnected()), this, SLOT(connectionEnded()));
    Q_ASSERT(success);

    m_connector.data()->go();

    // show modal
    this->exec();
}
示例#5
-1
// Accept connection from server and initiate the SSL handshake
void Server::acceptConnection()
{
	if (sockets.empty() == false)
		std::cout << "Server is mad efor 1 connection also. Need to update to handle multiple connections" << std::endl;

  QSslSocket *socket = dynamic_cast<QSslSocket *>(server.nextPendingConnection());
  assert(socket);


  // Report any SSL errors that occur
  connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(sslErrors(const QList<QSslError> &)));

  connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionFailure()));

  
  // QSslSocket emits the encrypted() signal after the encrypted connection is established
#define _USE_ENCRYPTION
#ifdef _USE_ENCRYPTION
  connect(socket, SIGNAL(encrypted()), this, SLOT(handshakeComplete()));
  socket->setPrivateKey(key);
  socket->setLocalCertificate(certificate);

  socket->setPeerVerifyMode(QSslSocket::VerifyNone);
  socket->startServerEncryption();
#else
  connect(socket, SIGNAL(disconnected()), this, SLOT(connectionClosed()));
  connect(socket, SIGNAL(readyRead()), this, SLOT(receiveMessage()));
  sockets.push_back(socket);
  std::cout << "Accepted connection from " << socket->peerAddress().toString().toStdString() << ":" << socket->peerPort() << " .Encrypted : " << socket->isEncrypted() << std::endl;
#endif
}