void HttpServer::newConnection(int s) { QSocket* socket = new QSocket(this); socket->setSocket(s); connect(socket, SIGNAL(readyRead()), this, SLOT(slotSocketReadyToRead())); connect(socket, SIGNAL(delayedCloseFinished()), this, SLOT(slotConnectionClosed())); connect(socket, SIGNAL(connectionClosed()), this, SLOT(slotConnectionClosed())); HttpClientHandler* handler = new HttpClientHandler(this,socket); clients.insert(socket,handler); Out(SYS_WEB|LOG_NOTICE) << "connection from "<< socket->peerAddress().toString() << endl; }
ICQClientSocket::ICQClientSocket(QSocket *s) #endif { sock = s; if (sock == NULL) #ifdef HAVE_KEXTSOCK_H sock = new KExtendedSocket; sock->setSocketFlags(KExtendedSocket::outputBufferedSocket ); #else sock = new QSocket(this); bConnected = false; #endif #ifdef HAVE_KEXTSOCK_H QObject::connect(sock, SIGNAL(connectionSuccess()), this, SLOT(slotConnected())); QObject::connect(sock, SIGNAL(lookupFinished(int)), this, SLOT(slotLookupFinished(int))); QObject::connect(sock, SIGNAL(connectionFailed(int)), this, SLOT(slotError(int))); QObject::connect(sock, SIGNAL(closed(int)), this, SLOT(slotError(int))); #else QObject::connect(sock, SIGNAL(connected()), this, SLOT(slotConnected())); QObject::connect(sock, SIGNAL(connectionClosed()), this, SLOT(slotConnectionClosed())); QObject::connect(sock, SIGNAL(error(int)), this, SLOT(slotError(int))); #endif QObject::connect(sock, SIGNAL(readyRead()), this, SLOT(slotReadReady())); QObject::connect(sock, SIGNAL(bytesWritten(int)), this, SLOT(slotBytesWritten(int))); bInWrite = false; #ifdef HAVE_KEXTSOCK_H if (s) sock->enableRead(true); #endif }
SIMClientSocket::SIMClientSocket(QSocket *s) { sock = s; if (sock == NULL) sock = new QSocket(this); QObject::connect(sock, SIGNAL(connected()), this, SLOT(slotConnected())); QObject::connect(sock, SIGNAL(connectionClosed()), this, SLOT(slotConnectionClosed())); QObject::connect(sock, SIGNAL(error(int)), this, SLOT(slotError(int))); QObject::connect(sock, SIGNAL(readyRead()), this, SLOT(slotReadReady())); QObject::connect(sock, SIGNAL(bytesWritten(int)), this, SLOT(slotBytesWritten(int))); bInWrite = false; }
InteractiveSMTPServerWindow::InteractiveSMTPServerWindow( QTcpSocket * socket, QWidget * parent ) : QWidget( parent ), mSocket( socket ) { QPushButton * but; Q_ASSERT( socket ); QVBoxLayout * vlay = new QVBoxLayout( this ); mTextEdit = new QTextEdit( this ); vlay->addWidget( mTextEdit, 1 ); QWidget *mLayoutWidget = new QWidget; vlay->addWidget( mLayoutWidget ); QHBoxLayout * hlay = new QHBoxLayout( mLayoutWidget ); mLineEdit = new QLineEdit( this ); mLabel = new QLabel( "&Response:", this ); mLabel->setBuddy( mLineEdit ); but = new QPushButton( "&Send", this ); hlay->addWidget( mLabel ); hlay->addWidget( mLineEdit, 1 ); hlay->addWidget( but ); connect( mLineEdit, SIGNAL(returnPressed()), SLOT(slotSendResponse()) ); connect( but, SIGNAL(clicked()), SLOT(slotSendResponse()) ); but = new QPushButton( "&Close Connection", this ); vlay->addWidget( but ); connect( but, SIGNAL(clicked()), SLOT(slotConnectionClosed()) ); connect( socket, SIGNAL(disconnected()), SLOT(slotConnectionClosed()) ); connect( socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(slotError(QAbstractSocket::SocketError)) ); connect( socket, SIGNAL(readyRead()), SLOT(slotReadyRead()) ); mLineEdit->setText( "220 hi there" ); mLineEdit->setFocus(); }
SslServerConnection::SslServerConnection(quint16 socketDescriptor, QObject *parent) : QThread(parent), blockSize (0) { // Set the new internal id internalId++; // Init the ssl socket this->socket = new QSslSocket(this); this->socket->setProtocol(QSsl::AnyProtocol); this->socket->setSocketDescriptor(socketDescriptor); // Now bind some signal of the ssl socket QObject::connect(socket, SIGNAL(connected()), SLOT(slotAcceptedClient())); QObject::connect(socket, SIGNAL(disconnected()), SLOT(slotConnectionClosed())); QObject::connect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater())); QObject::connect(socket, SIGNAL(modeChanged(QSslSocket::SslMode)), this, SLOT(slotModeChanged(QSslSocket::SslMode))); QObject::connect(socket, SIGNAL(readyRead()), SLOT(slotStartRead())); QObject::connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(slotError(QAbstractSocket::SocketError))); // Set the certificate and the key if (!SslKeyContent::instance()->keyIsValid()) { // Without a valid key, disconnect Debug::error(QLatin1String("No valid key")); socket->disconnectFromHost(); } else { // Key is valid QSslKey key(SslKeyContent::instance()->getKey(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, "server"); // If key is null disconnect and close the socket if (key.isNull()) { Debug::error(QLatin1String("Key is null")); socket->disconnectFromHost(); // Close the socket socket->close(); } else { if (socket->addCaCertificates(QCoreApplication::applicationDirPath() + QLatin1Char('/') + CACERTIFICATES_FILE)) { socket->setLocalCertificate(QCoreApplication::applicationDirPath() + QLatin1Char('/') + LOCALCERTIFICATE_FILE); socket->setPrivateKey(key); socket->startServerEncryption(); } } } }
KNetworkByteStream::KNetworkByteStream( QObject *parent, const char */*name*/ ) : ByteStream ( parent ) { kdDebug( 14151 ) << k_funcinfo << "Instantiating new KNetwork byte stream." << endl; // reset close tracking flag mClosing = false; mSocket = new KNetwork::KBufferedSocket; // make sure we get a signal whenever there's data to be read mSocket->enableRead( true ); // connect signals and slots QObject::connect( mSocket, SIGNAL ( gotError ( int ) ), this, SLOT ( slotError ( int ) ) ); QObject::connect( mSocket, SIGNAL ( connected ( const KResolverEntry& ) ), this, SLOT ( slotConnected () ) ); QObject::connect( mSocket, SIGNAL ( closed () ), this, SLOT ( slotConnectionClosed () ) ); QObject::connect( mSocket, SIGNAL ( readyRead () ), this, SLOT ( slotReadyRead () ) ); QObject::connect( mSocket, SIGNAL ( bytesWritten ( int ) ), this, SLOT ( slotBytesWritten ( int ) ) ); }
int SslServerConnection::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QThread::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: connectionIsClosed(); break; case 1: slotAcceptedClient(); break; case 2: slotStartRead(); break; case 3: slotConnectionClosed(); break; case 4: slotError((*reinterpret_cast< QAbstractSocket::SocketError(*)>(_a[1]))); break; case 5: slotModeChanged((*reinterpret_cast< QSslSocket::SslMode(*)>(_a[1]))); break; case 6: removeItemFromList((*reinterpret_cast< int(*)>(_a[1]))); break; case 7: recDig((*reinterpret_cast< int(*)>(_a[1]))); break; default: ; } _id -= 8; } return _id; }
void SIMClientSocket::connect(const char *_host, unsigned short _port) { port = _port; host = _host; #ifdef WIN32 bool bState; if (get_connection_state(bState) && !bState){ QTimer::singleShot(0, this, SLOT(slotConnectionClosed())); return; } #endif log(L_DEBUG, "Connect to %s:%u", host.c_str(), port); if (inet_addr(host.c_str()) == INADDR_NONE){ if (!host.empty() && (host[host.length() - 1] != '.')) host += "."; log(L_DEBUG, "Start resolve %s", host.c_str()); SIMSockets *s = static_cast<SIMSockets*>(getSocketFactory()); QObject::connect(s, SIGNAL(resolveReady(unsigned long, const char*)), this, SLOT(resolveReady(unsigned long, const char*))); s->resolve(host.c_str()); return; } resolveReady(inet_addr(host.c_str()), host.c_str()); }
KNotesNetworkReceiver::KNotesNetworkReceiver( QTcpSocket *s ) : QObject(), m_buffer( new QByteArray() ), m_sock( s ) { QString date = KGlobal::locale()->formatDateTime( QDateTime::currentDateTime(), KLocale::ShortDate, false ); // Add the remote IP or hostname and the date to the title, to help the // user guess who wrote it. m_titleAddon = QString( " [%1, %2]" ) .arg( m_sock->peerAddress().toString() ) .arg( date ); // Setup the communications connect( m_sock, SIGNAL(readyRead()), SLOT(slotDataAvailable()) ); connect( m_sock, SIGNAL(disconnected()), SLOT(slotConnectionClosed()) ); connect( m_sock, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(slotError(QAbstractSocket::SocketError))); // Setup the timer m_timer = new QTimer( this ); m_timer->setSingleShot( true ); connect( m_timer, SIGNAL(timeout()), SLOT(slotReceptionTimeout()) ); m_timer->start( MAXTIME ); }
void SIMClientSocket::timeout() { QTimer::singleShot(0, this, SLOT(slotConnectionClosed())); }