Exemplo n.º 1
0
/*!
    This virtual function is called by QLocalServer when a new connection
    is available. \a socketDescriptor is the native socket descriptor for
    the accepted connection.

    The base implementation creates a QLocalSocket, sets the socket descriptor
    and then stores the QLocalSocket in an internal list of pending
    connections. Finally newConnection() is emitted.

    Reimplement this function to alter the server's behavior
    when a connection is available.

    \sa newConnection(), nextPendingConnection(),
    QLocalSocket::setSocketDescriptor()
 */
void QLocalServer::incomingConnection(quintptr socketDescriptor)
{
    Q_D(QLocalServer);
    QLocalSocket *socket = new QLocalSocket(this);
    socket->setSocketDescriptor(socketDescriptor);
    d->pendingConnections.enqueue(socket);
    emit newConnection();
}
Exemplo n.º 2
0
void QFCgiFdConnectionBuilder::onActivated(int socket) {
  int so = accept(socket, 0, 0);

  if (so != -1) {
    QFCgi *fcgi = qobject_cast<QFCgi*>(parent());

    QLocalSocket *device = new QLocalSocket(this);
    device->setSocketDescriptor(so, QLocalSocket::ConnectedState, QIODevice::ReadWrite);

    QFCgiConnection *connection = new QFCgiConnection(device, fcgi);
    emit newConnection(connection);
  } else {
    qDebug("accept: %s", strerror(errno));
  }
}
    void         createSocket(qintptr sokDesc, TBackend bend) {
        isocket.ibackendType = bend;

        if        ( bend == ETcpSocket ) {
            QTcpSocket* sok    = new QTcpSocket( q_func() );
            isocket.itcpSocket = sok;
            sok->setSocketDescriptor(sokDesc);

            QObject::connect(sok,       &QTcpSocket::readyRead, [this](){
                onReadyRead();
            });
            QObject::connect(sok,       &QTcpSocket::bytesWritten, [this](){
                if ( isocket.itcpSocket->bytesToWrite() == 0  &&  ilastResponse )
                    emit ilastResponse->allBytesWritten();
            });
            QObject::connect(sok,       &QTcpSocket::disconnected,
                             q_func(),  &QHttpConnection::disconnected,
                             Qt::QueuedConnection);

        } else if ( bend == ELocalSocket ) {
            QLocalSocket* sok    = new QLocalSocket( q_func() );
            isocket.ilocalSocket = sok;
            sok->setSocketDescriptor(sokDesc);

            QObject::connect(sok,       &QLocalSocket::readyRead, [this](){
                onReadyRead();
            });
            QObject::connect(sok,       &QLocalSocket::bytesWritten, [this](){
                if ( isocket.ilocalSocket->bytesToWrite() == 0  &&  ilastResponse )
                    emit ilastResponse->allBytesWritten();
            });
            QObject::connect(sok,       &QLocalSocket::disconnected,
                             q_func(),  &QHttpConnection::disconnected,
                             Qt::QueuedConnection);
        }

    }
Exemplo n.º 4
0
QLocalSocket *Nuria::Internal::LocalServer::handleToSocket (qintptr handle) {
	QLocalSocket *socket = new QLocalSocket;
	socket->setSocketDescriptor (handle);
	return socket;
	
}