当前位置: 首页>>代码示例>>C++>>正文


C++ QLocalSocket::setSocketDescriptor方法代码示例

本文整理汇总了C++中QLocalSocket::setSocketDescriptor方法的典型用法代码示例。如果您正苦于以下问题:C++ QLocalSocket::setSocketDescriptor方法的具体用法?C++ QLocalSocket::setSocketDescriptor怎么用?C++ QLocalSocket::setSocketDescriptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QLocalSocket的用法示例。


在下文中一共展示了QLocalSocket::setSocketDescriptor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: newConnection

/*!
    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();
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:23,代码来源:qlocalserver.cpp

示例2: onActivated

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));
  }
}
开发者ID:albert-mirzoyan,项目名称:qfcgi,代码行数:15,代码来源:fdbuilder.cpp

示例3: createSocket

    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);
        }

    }
开发者ID:Diganth,项目名称:plex-media-player,代码行数:37,代码来源:qhttpserverconnection_private.hpp

示例4:

QLocalSocket *Nuria::Internal::LocalServer::handleToSocket (qintptr handle) {
	QLocalSocket *socket = new QLocalSocket;
	socket->setSocketDescriptor (handle);
	return socket;
	
}
开发者ID:NuriaProject,项目名称:Network,代码行数:6,代码来源:localserver.cpp


注:本文中的QLocalSocket::setSocketDescriptor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。