本文整理汇总了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();
}
示例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));
}
}
示例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);
}
}
示例4:
QLocalSocket *Nuria::Internal::LocalServer::handleToSocket (qintptr handle) {
QLocalSocket *socket = new QLocalSocket;
socket->setSocketDescriptor (handle);
return socket;
}