void PMaildServerBase::noSsl() { connect(sock, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); connect(sock, SIGNAL(bytesWritten(qint64)), this, SLOT(socketBytesWritten(qint64))); sock->setSocketOption(QAbstractSocket::KeepAliveOption, 1); status = VALID; welcome(); // read data if any is already in the pipe if (sock->bytesAvailable()) socketReadyRead(); }
TcpClient::TcpClient(QObject *parent) : QObject(parent) { tcpSocket = new QTcpSocket(this); eAuth = new EAuthService(this); mainWindow = (MainWindow*)parent; windowFacade = mainWindow->getWindowFacade(); settings = ClientSettings::Instance(); debugLogger = new DebugLogger(); if(tcpSocket) { connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); connect(tcpSocket, SIGNAL(disconnected()), this, SLOT(disconnectedFromHost())); tcpSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1); } xmlParser = new XmlParserThread(parent); connect(this, SIGNAL(addToQueue(QByteArray)), xmlParser, SLOT(addData(QByteArray))); connect(this, SIGNAL(updateHighlighterSettings()), xmlParser, SLOT(updateHighlighterSettings())); connect(xmlParser, SIGNAL(writeSettings()), this, SLOT(writeSettings())); connect(xmlParser, SIGNAL(writeModeSettings()), this, SLOT(writeModeSettings())); if(MainWindow::DEBUG) { this->loadMockData(); } }
void SslClient::establish(const QString& host, quint16 port) { threadLock_ = new QMutex(); threadEvent_ = new QWaitCondition(); QMutexLocker blocked(threadLock_); host_ = host; port_ = port; start(); threadEvent_->wait(threadLock_); if(ssl_.isNull() || running_ == false) Q_ASSERT_X(ssl_.isNull() || running_ == false, "SslClient::establish", "Cannot start SslClient's thread"); connect(ssl_.data(), SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState)), Qt::DirectConnection); connect(ssl_.data(), SIGNAL(encrypted()), this, SLOT(socketEncrypted()), Qt::DirectConnection); connect(ssl_.data(), SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError)), Qt::DirectConnection); connect(ssl_.data(), SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrors(QList<QSslError>)), Qt::DirectConnection); connect(ssl_.data(), SIGNAL(readyRead()), this, SLOT(socketReadyRead()), Qt::DirectConnection); ConfigureForLMAX(); }
/*! Receive newConnection() signals from the tcp server, when a client connects. Respond by accepting, creating a socket, and piping the traffic to and from a micro_httpd instance. */ void InetdAdaptor::newConnection() { HttpWorker *worker = new HttpWorker(); mShowingProgressLock.lock(); if ( mShowingProgress == 0 ) { // only show progress for one tcp request, if another comes in at // the same time, don't bother showing progress for that mShowingProgress = worker; mShowingProgressLock.unlock(); emit adaptorMessage( tr( "Receiving http request" )); emit progressValue( 10 ); } else { mShowingProgressLock.unlock(); } worker->socket = mTcpServer->nextPendingConnection(); Q_ASSERT( worker->socket != NULL ); connect( worker->socket, SIGNAL(disconnected()), this, SLOT(disconnected())); connect( worker->socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); if ( worker == mShowingProgress ) emit progressValue( 20 ); mWorkersLock.lock(); mWorkers.append( worker ); mWorkersLock.unlock(); }
SmtpClient::SmtpClient(const QString & host, int port, ConnectionType ct) : name("localhost"), authMethod(AuthPlain), connectionTimeout(5000), responseTimeout(5000) { if (ct == TcpConnection) this->useSsl = false; else if (ct == SslConnection) this->useSsl = true; if (useSsl == false) socket = new QTcpSocket(this); else socket = new QSslSocket(this); this->host = host; this->port = port; connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); }
IndiClient::IndiClient(const int &attempts) : mPort(indi::PORT), mAttempts(attempts), mAttempt(1) { connect(&mQTcpSocket, SIGNAL(connected()), SLOT(socketConnected())); connect(&mQTcpSocket, SIGNAL(disconnected()), SLOT(socketDisconnected())); connect(&mQTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError))); connect(&mQTcpSocket, SIGNAL(readyRead()), SLOT(socketReadyRead())); }
tlen::tlen( QObject* parent ): QObject( parent ) { state = tlen::Disconnected; hostname = "s1.tlen.pl"; hostport = 443; Secure = false; Reconnect = false; Status= tlen::unavailable; Descr=""; tmpDoc=new QDomDocument; socket=new QTcpSocket(); ping=new QTimer(); connect(socket, SIGNAL(connected()), this, SLOT(socketConnected())); connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); connect(this, SIGNAL(tlenLoggedIn()), this, SLOT(writeStatus())); connect(this, SIGNAL(statusUpdate()), this, SLOT(writeStatus())); connect(this, SIGNAL(eventReceived(QDomNode)), this, SLOT(event(QDomNode))); connect(ping, SIGNAL(timeout()), this, SLOT(sendPing())); srand(time(NULL)); }
/*! Connect to the configured port and host for the device and setting up the socket. */ void DeviceConnector::connect() { if ( mSocket ) // already connected return; emit startingConnect(); loginDone = false; mSocket = new QTcpSocket(); QObject::connect( mSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError()) ); mSocket->connectToHost( QHostAddress( "10.10.10.20" ), 4245 ); if ( !mSocket->waitForConnected() ) { emit deviceConnMessage( tr( "Error connecting to device:" ) + mSocket->errorString() ); delete mSocket; mSocket = 0; return; } QObject::connect( mSocket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()) ); QObject::connect( mSocket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()) ); emit deviceConnMessage( tr( "Device connected" ) ); emit finishedConnect(); }
ZephyrXtreme::ZephyrXtreme(int id,QObject *parent) : LPSwitcher(id,LPSwitcher::TypeZephyrXtreme,parent) { zep_locked=false; zep_xmt_algo=LPSwitcher::XmtAlgoLast; zep_rcv_algo=LPSwitcher::RcvAlgoLast; zep_channel_rate=LPSwitcher::ChannelRateLast; zep_pending_channel_rate=LPSwitcher::ChannelRateLast; zep_sample_rate=0; zep_pending_sample_rate=0; for(int i=0;i<2;i++) { zep_line_state[i]=LPSwitcher::StateOffline; zep_dialed_string[i]=""; zep_pending_string[i]=""; } zep_device=new LPTTYDevice(this); zep_device->setSpeed(ZEPHYRXTREME_SPEED); zep_device->setWordLength(ZEPHYRXTREME_WORD_LENGTH); zep_device->setParity(ZEPHYRXTREME_PARITY); zep_device->setFlowControl(ZEPHYRXTREME_FLOW_CONTROL); connect(zep_device,SIGNAL(readyRead()),this,SLOT(readyReadData())); zep_socket=new QTcpSocket(this); connect(zep_socket,SIGNAL(connected()),this,SLOT(connectedData())); connect(zep_socket,SIGNAL(disconnected()),this,SLOT(disconnectedData())); connect(zep_socket,SIGNAL(readyRead()),this,SLOT(socketReadyRead())); zep_poll_timer=new QTimer(this); connect(zep_poll_timer,SIGNAL(timeout()),this,SLOT(pollData())); }
Qip::Qip() { state = Start; socket = new QSocket( this ); connect( socket, SIGNAL(connected()), SLOT(socketConnected()) ); connect( socket, SIGNAL(connectionClosed()), SLOT(socketConnectionClosed()) ); connect( socket, SIGNAL(readyRead()), SLOT(socketReadyRead()) ); connect( socket, SIGNAL(error(int)), SLOT(socketError(int)) ); }
void ServerController::newConnection() { m_socket = m_server->nextPendingConnection(); qDebug() << "Server got new connection"; connect(m_socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); connect(m_socket, SIGNAL(bytesWritten(qint64)), this, SLOT(socketBytesWritten(qint64))); connect(m_socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); }
void ClientInfo::connectToServer() { delete socket; socket = new QSocket( this ); connect( socket, SIGNAL(connected()), SLOT(socketConnected()) ); connect( socket, SIGNAL(connectionClosed()), SLOT(socketConnectionClosed()) ); connect( socket, SIGNAL(readyRead()), SLOT(socketReadyRead()) ); connect( socket, SIGNAL(error(int)), SLOT(socketError(int)) ); socket->connectToHost( edHost->text(), edPort->text().toInt() ); }
Client::Client(chatdialog *chat, QObject *parent) : QObject(parent) { chatDialog = chat; socket = new QTcpSocket(this); socket->connectToHost("127.0.0.1", 49998); connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); }
bool QNetworkAccessDebugPipeBackend::waitForDownstreamReadyRead(int ms) { readyReadEmitted = false; if (socket.bytesAvailable()) { socketReadyRead(); if (readyReadEmitted) return true; } socket.waitForReadyRead(ms); return readyReadEmitted; }
c_client::c_client(const QString &host, Q_UINT16 port, MyDialog1 *mdlg) { socket = new QSocket(this); connect(socket, SIGNAL(connected()), SLOT(socketConnected())); connect(socket, SIGNAL(connectionClosed()), SLOT(socketConnectionClosed())); connect(socket, SIGNAL(readyRead()), SLOT(socketReadyRead())); connect(socket, SIGNAL(error(int)), SLOT(socketError(int))); mydlg = mdlg; // mydlg->statusEdit->append("Michon: Trying to connect to the server\n"); socket->connectToHost(host, port); }
Client::Client(QString userId, QObject * parent) : QObject(parent), m_user_id(userId), m_state(Client::Disconnected) { connect(&m_socket, SIGNAL(connected()), this, SLOT(authenticate())); connect(&m_socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); connect(&m_socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); connect(&m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); }
void QNetworkAccessDebugPipeBackend::socketDisconnected() { socketReadyRead(); if (incomingPacketSize == 0 && socket.bytesToWrite() == 0) { // normal close finished(); } else { // abnormal close QString msg = QObject::tr("Remote host closed the connection prematurely on %1") .arg(url().toString()); error(QNetworkReply::RemoteHostClosedError, msg); finished(); } }
void ClientListener::newConnection() { m_socket = m_tcpServer->nextPendingConnection(); m_tcpServer->close(); connect(m_socket, SIGNAL(hostFound()), SLOT(socketHostFound())); connect(m_socket, SIGNAL(connected()), SLOT(socketConnected())); connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError))); connect(m_socket, SIGNAL(readyRead()), SLOT(socketReadyRead())); connect(m_socket, SIGNAL(bytesWritten(qint64)), SLOT(socketBytesWritten(qint64))); connect(m_socket, SIGNAL(disconnected()), SLOT(socketDisconnected())); changeState(Handshaking); m_stream.setDevice(m_socket); }
qint64 ShoutCastIODevice::readData(char *data, qint64 maxlen) { // the decoder wants more data from the stream // but first we must filter out any headers and metadata // first fill our buffer with as much data as is available socketReadyRead(); if (m_buffer->readBufAvail() == 0) { LOG(VB_PLAYBACK, LOG_ERR, "ShoutCastIODevice: No data in buffer!!"); switchToState(STOPPED); return -1; } if (m_state == STREAMING_META && parseMeta()) switchToState(STREAMING); if (m_state == STREAMING) { // take maxlen or what ever is left till the next metadata if (maxlen > m_bytesTillNextMeta) maxlen = m_bytesTillNextMeta; maxlen = m_buffer->read(data, maxlen); m_bytesTillNextMeta -= maxlen; if (m_bytesTillNextMeta == 0) switchToState(STREAMING_META); } if (m_state != STOPPED) LOG(VB_NETWORK, LOG_INFO, QString("ShoutCastIODevice: %1 kb in buffer, btnm=%2/%3 " "state=%4, len=%5") .arg(m_buffer->readBufAvail() / 1024, 4) .arg(m_bytesTillNextMeta, 4) .arg(m_response->getMetaint()) .arg(stateString (m_state)) .arg(maxlen)); else LOG(VB_NETWORK, LOG_INFO, QString("ShoutCastIODevice: stopped")); return maxlen; }
void SslClient::secureConnect() { if (!socket) { socket = new QSslSocket(this); connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); connect(socket, SIGNAL(encrypted()), this, SLOT(socketEncrypted())); connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrors(QList<QSslError>))); connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); } socket->connectToHostEncrypted(form->hostNameEdit->text(), form->portBox->value()); updateEnabledState(); }
SmtpClient::SmtpClient(const QString & host, int port, ConnectionType connectionType) : name("localhost"), authMethod(AuthPlain), connectionTimeout(5000), responseTimeout(5000) { setConnectionType(connectionType); this->host = host; this->port = port; connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); }
void QtTelnetPrivate::setSocket(QTcpSocket *s) { if (socket) { q->logout(); socket->flush(); } delete socket; socket = s; connected = false; if (socket) { connect(socket, SIGNAL(connected()), this, SLOT(socketConnected())); connect(socket, SIGNAL(disconnected()), this, SLOT(socketConnectionClosed())); connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); } }
void SslClient::setupSecureSocket() { if (socket) return; socket = new QSslSocket(this); connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); connect(socket, SIGNAL(encrypted()), this, SLOT(socketEncrypted())); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrors(QList<QSslError>))); connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); }
TCPClient::TCPClient( const QString &host, Q_UINT16 port ) { socket = new QSocket( this ); connect( socket, SIGNAL(connected()),SLOT(socketConnected()) ); connect( socket, SIGNAL(connectionClosed()),SLOT(socketConnectionClosed()) ); connect( socket, SIGNAL(readyRead()),SLOT(socketReadyRead()) ); connect( socket, SIGNAL(error(int)),SLOT(socketError(int)) ); // connect to the server printf("Trying to connect to the server %s:%d\n",(const char*)host,port); socket->connectToHost( host, port ); ds=NULL; ds=new QDataStream ( socket ); lostSum=0; go=false; iWin=false; error=false; }
ShoutCastIODevice::ShoutCastIODevice(void) : m_redirects (0), m_scratchpad_pos (0), m_state (NOT_CONNECTED) { m_socket = new QTcpSocket; m_response = new ShoutCastResponse; connect(m_socket, SIGNAL(hostFound()), SLOT(socketHostFound())); connect(m_socket, SIGNAL(connected()), SLOT(socketConnected())); connect(m_socket, SIGNAL(disconnected()), SLOT(socketConnectionClosed())); connect(m_socket, SIGNAL(readyRead()), SLOT(socketReadyRead())); connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError))); switchToState(NOT_CONNECTED); setOpenMode(ReadWrite); }
void QNetworkAccessDebugPipeBackend::open() { socket.connectToHost(url().host(), url().port(12345)); socket.setReadBufferSize(ReadBufferSize); connect(&socket, SIGNAL(readyRead()), SLOT(socketReadyRead())); connect(&socket, SIGNAL(bytesWritten(qint64)), SLOT(socketBytesWritten(qint64))); connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError())); connect(&socket, SIGNAL(disconnected()), SLOT(socketDisconnected())); bareProtocol = url().queryItemValue(QLatin1String("bare")) == QLatin1String("1"); if (!bareProtocol) { // "Handshake": // send outgoing metadata and the URL being requested DataPacket packet; //packet.metaData = request().metaData(); packet.data = url().toEncoded(); send(packet); } }
//! [1] void SslClient::secureConnect() { if (!m_socket) { // Create a new SSL socket and connect against its signals to receive notifications about state changes m_socket = new QSslSocket(this); connect(m_socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); connect(m_socket, SIGNAL(encrypted()), this, SLOT(socketEncrypted())); connect(m_socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrors(QList<QSslError>))); connect(m_socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); } // Trigger the SSL-handshake m_socket->connectToHostEncrypted(m_hostName, m_port); updateEnabledState(); }
void QgsAuthSslImportDialog::secureConnect() { if ( leServer->text().isEmpty() ) { return; } leServer->setStyleSheet( QLatin1String( "" ) ); clearStatusCertificateConfig(); if ( !mSocket ) { mSocket = new QSslSocket( this ); connect( mSocket, SIGNAL( stateChanged( QAbstractSocket::SocketState ) ), this, SLOT( socketStateChanged( QAbstractSocket::SocketState ) ) ); connect( mSocket, SIGNAL( connected() ), this, SLOT( socketConnected() ) ); connect( mSocket, SIGNAL( disconnected() ), this, SLOT( socketDisconnected() ) ); connect( mSocket, SIGNAL( encrypted() ), this, SLOT( socketEncrypted() ) ); connect( mSocket, SIGNAL( error( QAbstractSocket::SocketError ) ), this, SLOT( socketError( QAbstractSocket::SocketError ) ) ); connect( mSocket, SIGNAL( sslErrors( QList<QSslError> ) ), this, SLOT( sslErrors( QList<QSslError> ) ) ); connect( mSocket, SIGNAL( readyRead() ), this, SLOT( socketReadyRead() ) ); } mSocket->setCaCertificates( mTrustedCAs ); if ( !mTimer ) { mTimer = new QTimer( this ); connect( mTimer, SIGNAL( timeout() ), this, SLOT( destroySocket() ) ); } mTimer->start( spinbxTimeout->value() * 1000 ); mSocket->connectToHost( leServer->text(), spinbxPort->value() ); updateEnabledState(); }
ClientStream::ClientStream( QSslSocket *socket, QObject *parent ) : Stream( parent ), d(new Private()) { d->socket = socket; connect( d->socket, SIGNAL(connected()), SLOT(socketConnected()) ); connect( d->socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError)) ); connect(d->socket, SIGNAL(disconnected()), SLOT(socketDisconnected())); connect(d->socket, SIGNAL(readyRead()), SLOT(socketReadyRead())); connect(d->socket, SIGNAL(bytesWritten(qint64)), SLOT(socketBytesWritten(qint64))); connect( &d->client, SIGNAL(outgoingData(QByteArray)), SLOT (cp_outgoingData(QByteArray)) ); connect( &d->client, SIGNAL(incomingData()), SLOT (cp_incomingData()) ); d->noop_time = 0; connect(&d->noopTimer, SIGNAL(timeout()), SLOT(doNoop())); }
void QNetworkAccessDebugPipeBackend::open() { socket.connectToHost(url().host(), url().port(12345)); socket.setReadBufferSize(ReadBufferSize); // socket ready read -> we can push from socket to downstream connect(&socket, SIGNAL(readyRead()), SLOT(socketReadyRead())); connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError())); connect(&socket, SIGNAL(disconnected()), SLOT(socketDisconnected())); connect(&socket, SIGNAL(connected()), SLOT(socketConnected())); // socket bytes written -> we can push more from upstream to socket connect(&socket, SIGNAL(bytesWritten(qint64)), SLOT(socketBytesWritten(qint64))); bareProtocol = url().queryItemValue(QLatin1String("bare")) == QLatin1String("1"); if (operation() == QNetworkAccessManager::PutOperation) { uploadByteDevice = createUploadByteDevice(); QObject::connect(uploadByteDevice, SIGNAL(readyRead()), this, SLOT(uploadReadyReadSlot())); QMetaObject::invokeMethod(this, "uploadReadyReadSlot", Qt::QueuedConnection); } }