本文整理汇总了C++中QAbstractSocket::setSocketDescriptor方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractSocket::setSocketDescriptor方法的具体用法?C++ QAbstractSocket::setSocketDescriptor怎么用?C++ QAbstractSocket::setSocketDescriptor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractSocket
的用法示例。
在下文中一共展示了QAbstractSocket::setSocketDescriptor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: incomingConnection
void XmlRpcServer::incomingConnection( int socketDescriptor )
{
#ifdef DEBUG_XMLRPC
qDebug() << this << "new incoming connection";
#endif
QAbstractSocket * s = NULL;
#ifndef QT_NO_OPENSSL
if ( sslParams != NULL && !sslParams->certificate.isNull() )
{
s = new QSslSocket( this );
s->setSocketDescriptor( socketDescriptor );
((QSslSocket *)s)->setLocalCertificate( sslParams->certificate );
((QSslSocket *)s)->setPrivateKey( sslParams->privateKey );
((QSslSocket *)s)->setCaCertificates( sslParams->ca );
}
else
{
s = new QTcpSocket( this );
s->setSocketDescriptor( socketDescriptor );
}
#else
s = new QTcpSocket( this );
s->setSocketDescriptor( socketDescriptor );
#endif
Q_ASSERT( s->state() == QAbstractSocket::ConnectedState );
connect( s, SIGNAL(disconnected()), this, SLOT(slotSocketDisconnected()) );
HttpServer * p = new HttpServer( s );
connect( p, SIGNAL(protocolTimeout(Protocol*)),
this, SLOT(slotProtocolTimeout(Protocol*)) );
connect( p, SIGNAL(parseError(HttpServer*)),
this, SLOT(slotParseError(HttpServer*)) );
connect( p, SIGNAL(requestReceived(HttpServer*, const QHttpRequestHeader&, const QByteArray&)),
this, SLOT(slotRequestReceived(HttpServer*, const QHttpRequestHeader&, const QByteArray&)) );
connect( p, SIGNAL(replySent(HttpServer*)),
this, SLOT(slotReplySent(HttpServer*)) );
}
示例2: newDevice
QIODevice* EmbraceChunker::newDevice()
{
QAbstractSocket* lsocket = new QAbstractSocket(QAbstractSocket::UnknownSocketType, 0);
int sock = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL));
if (sock < 0) {
std::cerr << "socket : %s\n" << strerror(errno) << std::endl;
}
if (setsockopt(sock, SOL_SOCKET, SO_RCVBUFFORCE, (char *)&_socketBufferSize, sizeof(unsigned long long)) < 0) {
std::cerr << "sock opt : %s\n" << strerror(errno) << std::endl;
}
lsocket->setSocketDescriptor(sock);
return lsocket;
}