void PersistentEchoRequestHandler::handleRequest() { _socket = new QTcpSocket(this); connect(_socket, SIGNAL(disconnected()), SIGNAL(done())); connect(_socket, SIGNAL(readyRead()), SLOT(onSocketReadyRead())); _socket->setSocketDescriptor(_descriptor); }
InfoServiceClient::InfoServiceClient(QObject *parent) : QObject(parent) { bool ssl = AppSettings::GetKey(AppSettings::Connection_Rover_Info_SSL).toBool(); _socket = new Socket("Info service", ssl, this); connect(_socket, SIGNAL(readyRead()), this, SLOT(onSocketReadyRead())); }
void DesktopUser::setSocket(QTcpSocket *socket) { socket_ = socket; connect(socket_, SIGNAL(connected()), SIGNAL(connected())); connect(socket_, SIGNAL(disconnected()), SIGNAL(disconnected())); connect(socket_, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(onSocketError(QAbstractSocket::SocketError))); connect(socket_, SIGNAL(readyRead()), SLOT(onSocketReadyRead())); }
Asterisk::Asterisk(QObject *parent, QString host, quint16 port) : QObject(parent), host(host), port(port) { connect(&socket, SIGNAL(disconnected()), SLOT(onSocketDisconnected())); connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(onSocketError(QAbstractSocket::SocketError))); connect(&socket, SIGNAL(readyRead()), SLOT(onSocketReadyRead())); qDebug("Asterisk Manager initialized"); }
void Client::setSocket(QTcpSocket *socket) { this->socket = socket; this->socket->setParent(this); socketIn.setDevice(socket); socketOut.setDevice(socket); connect(socket, SIGNAL(disconnected()), SLOT(onSocketDisconnected())); connect(socket, SIGNAL(disconnected()), SIGNAL(socketDisconnected())); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(onSocketError(QAbstractSocket::SocketError))); connect(socket, SIGNAL(readyRead()), SLOT(onSocketReadyRead())); initiateHandshake(); resetHeartbeatTimer(); }
EnginioBackendConnection::EnginioBackendConnection(QObject *parent) : QObject(parent) , _protocolOpcode(ContinuationFrameOp) , _protocolDecodeState(HandshakePending) , _sentCloseFrame(false) , _isFinalFragment(false) , _isPayloadMasked(false) , _payloadLength(0) , _tcpSocket(new QTcpSocket(this)) { _tcpSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1); _tcpSocket->setSocketOption(QAbstractSocket::KeepAliveOption, 1); QObject::connect(_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onSocketConnectionError(QAbstractSocket::SocketError))); QObject::connect(_tcpSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(onSocketStateChanged(QAbstractSocket::SocketState))); QObject::connect(_tcpSocket, SIGNAL(readyRead()), this, SLOT(onSocketReadyRead())); }
// ----------------------------------------------------------------------------- bool NetworkDeviceController::open() { // set some reasonable default values QString address("192.168.1.100"); int portnum = 8090; // was an address specified? if (m_device.length()) { // if so, split it into ip address and port number QStringList ssplit = m_device.split(":", QString::SkipEmptyParts); if (ssplit.size() != 2) { Logger::err("NetworkDevice: invalid address format (addr:port)\n"); return false; } address = ssplit[0]; portnum = ssplit[1].toInt(); } Logger::info(tr("NetworkDevice: creating network device %1 port %2\n") .arg(address).arg(portnum)); // attempt to create and connect to the network socket m_sock = new QTcpSocket(); connect(m_sock, SIGNAL(readyRead()), this, SLOT(onSocketReadyRead())); connect(m_sock, SIGNAL(disconnected()), this, SLOT(onSocketDisconnected())); connect(m_sock, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError))); // attempt to connect to the specified address:port m_sock->connectToHost(address, portnum); if (!m_sock->waitForConnected(3000)) { emit connectionStatusChanged(QString("Connection failed"), false); Logger::warn("NetworkDevice: connection timed out\n"); return false; } emit connectionStatusChanged(QString("Connected to ") + m_device, true); Logger::info(tr("NetworkDevice: connected to ") + m_device + "\n"); emit flightStateChanged(FCS_STATE_GROUNDED); startup(); return true; }
DefaultConnection::DefaultConnection(IConnectionPlugin *APlugin, QObject *AParent) : QObject(AParent) { FPlugin = APlugin; FSrvQueryId = START_QUERY_ID; connect(&FDns, SIGNAL(resultsReady(int, const QJDns::Response &)),SLOT(onDnsResultsReady(int, const QJDns::Response &))); connect(&FDns, SIGNAL(error(int, QJDns::Error)),SLOT(onDnsError(int, QJDns::Error))); connect(&FDns, SIGNAL(shutdownFinished()),SLOT(onDnsShutdownFinished())); FSocket.setProtocol(QSsl::AnyProtocol); connect(&FSocket, SIGNAL(connected()), SLOT(onSocketConnected())); connect(&FSocket, SIGNAL(encrypted()), SLOT(onSocketEncrypted())); connect(&FSocket, SIGNAL(readyRead()), SLOT(onSocketReadyRead())); connect(&FSocket, SIGNAL(modeChanged(QSslSocket::SslMode)), SIGNAL(modeChanged(QSslSocket::SslMode))); connect(&FSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(onSocketError(QAbstractSocket::SocketError))); connect(&FSocket, SIGNAL(sslErrors(const QList<QSslError> &)), SLOT(onSocketSSLErrors(const QList<QSslError> &))); connect(&FSocket, SIGNAL(disconnected()), SLOT(onSocketDisconnected())); FConnectTimer.setSingleShot(true); FConnectTimer.setInterval(CONNECT_TIMEOUT); connect(&FConnectTimer,SIGNAL(timeout()),SLOT(onConnectTimerTimeout())); }
void KCToolServer::onNewConnection() { while(this->hasPendingConnections()) { QTcpSocket *socket = this->nextPendingConnection(); connect(socket, SIGNAL(readyRead()), this, SLOT(onSocketReadyRead())); } }