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


C++ disconnected函数代码示例

本文整理汇总了C++中disconnected函数的典型用法代码示例。如果您正苦于以下问题:C++ disconnected函数的具体用法?C++ disconnected怎么用?C++ disconnected使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: ClientSocket

/*线程启动时调用的函数*/
void ServerThread::run()
{
    _clientSocket = new ClientSocket();
    /*用ServerThread保存的套接字描述符初始化套接字*/
    if(!_clientSocket->setSocketDescriptor(_descriptor))
    {
        qDebug("socket create fail!");
        this->finished();
        return;
    }
    /*连接消息发送信号*/
    connect(this,SIGNAL(sendData(int,qint32,QVariant)),
            _clientSocket,SLOT(sendData(int,qint32,QVariant)));
    /*连接消息到达信号*/
    connect(_clientSocket,SIGNAL(messageArrive(int,qint32,QVariant)),
            this,SIGNAL(messageArrive(int,qint32,QVariant)));
    /*连接客户端断开信号*/
    connect(_clientSocket,SIGNAL(disconnected()),this,SLOT(threadFinished()));
    /*连接数据到达信号*/
    connect(_clientSocket,SIGNAL(readyRead()),_clientSocket,SLOT(readData()));
    exec();
}
开发者ID:AlanForeverAi,项目名称:Exams,代码行数:23,代码来源:server.cpp

示例2: QTcpSocket

squeezeListner::squeezeListner(QObject *parent,QString mIpaddr,QString mPortNr)
 :QObject ( parent )
{
    bool ret;
    ret=false;

    port_nr=mPortNr;
    ip_addr=mIpaddr;
    tcpSocket = new QTcpSocket(this);
    if (QObject::connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readData1())));
        qDebug()<<"Signal ok";
    QObject::connect(tcpSocket, SIGNAL(disconnected()),this,SLOT(disConnected()));

    tcpSocket->abort();
    tcpSocket->connectToHost(ip_addr,port_nr.toInt());

    if (tcpSocket->waitForConnected(1000))
    {
        ret=true;
        qDebug("Connected!");
    }
}
开发者ID:dubstar-04,项目名称:squeezecontroll,代码行数:22,代码来源:squeezelistner.cpp

示例3: KDSoapServerSocket

KDSoapServerSocket *KDSoapSocketList::handleIncomingConnection(int socketDescriptor)
{
    KDSoapServerSocket *socket = new KDSoapServerSocket(this, m_serverObject);
    socket->setSocketDescriptor(socketDescriptor);

#ifndef QT_NO_OPENSSL
    if (m_server->features() & KDSoapServer::Ssl) {
        // We could call a virtual "m_server->setSslConfiguration(socket)" here,
        // if more control is needed (e.g. due to SNI)
        if (!m_server->sslConfiguration().isNull()) {
            socket->setSslConfiguration(m_server->sslConfiguration());
        }
        socket->startServerEncryption();
    }
#endif

    QObject::connect(socket, SIGNAL(disconnected()),
                     socket, SLOT(deleteLater()));
    m_sockets.insert(socket);
    connect(socket, SIGNAL(socketDeleted(KDSoapServerSocket*)), this, SLOT(socketDeleted(KDSoapServerSocket*)));
    return socket;
}
开发者ID:Augus-Wang,项目名称:KDSoap,代码行数:22,代码来源:KDSoapSocketList.cpp

示例4: QObject

CloudConnection::CloudConnection(const QUrl &authenticationServer, const QUrl &proxyServer, QObject *parent) :
    QObject(parent),
    m_authenticationServerUrl(authenticationServer),
    m_proxyServerUrl(proxyServer),
    m_connected(false),
    m_error(Cloud::CloudErrorNoError)
{
    m_reconnectionTimer = new QTimer(this);
    m_reconnectionTimer->setSingleShot(false);
    connect(m_reconnectionTimer, &QTimer::timeout, this, &CloudConnection::reconnectionTimeout);

    m_connection = new QWebSocket("guhd", QWebSocketProtocol::Version13, this);
    connect(m_connection, SIGNAL(connected()), this, SLOT(onConnected()));
    connect(m_connection, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
    connect(m_connection, SIGNAL(textMessageReceived(QString)), this, SLOT(onTextMessageReceived(QString)));
    connect(m_connection, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onError(QAbstractSocket::SocketError)));

    m_authenticator = new CloudAuthenticator("0631d42ba0464e4ebd4b78b15c53f532", "b7919ebf3bcf48239f348e764744079b", this);
    m_authenticator->setUrl(m_authenticationServerUrl);

    connect(m_authenticator, &CloudAuthenticator::authenticationChanged, this, &CloudConnection::onAuthenticationChanged);
}
开发者ID:ni-cc,项目名称:guh,代码行数:22,代码来源:cloudconnection.cpp

示例5: QWidget

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();
}
开发者ID:pvuorela,项目名称:kcalcore,代码行数:39,代码来源:interactivesmtpserver.cpp

示例6: qDebug

//void TcpClientSocket::dataReceived(QString msg)
//{
////        emit updateClients(msg,msg.length());
//}
void TcpClientSocket::dataReceived(){
    QString name=this->readAll();
    if(isfirst==6666){
        qDebug()<<name;
        QStringList tmp=name.split(" ");
        if(q.Iscontent(tmp[0],tmp[2].toInt())){
            classname=tmp[2].toInt();
            if(classname>=3){
                return;
            }
            this->write("yes\n");
            this->write(q.getquestioncontent().toUtf8());
            this->flush();
            this->write(q.avaqueue(classname).toLatin1());
            this->flush();
            this->write("\nmdzz");
            this->flush();
        }else{
            this->write("no");
        }
        qDebug()<< "登陆 ";
    }else{
        qDebug() << "选题内容 " <<name;
        QStringList tmp=name.split("|");
        classname=tmp[2].toInt();
        qDebug() << classname;
        qDebug()<< tmp;
        if(q.selectquestion(tmp[0],classname,tmp[1].toInt())){
            this->write("OK");
            emit disconnected(this->socketDescriptor());
        }else{
            qDebug() << "error\n";
            this->write("error");
            this->write(q.avaqueue(classname).toLatin1());
            this->flush();
        }
        qDebug()<< "选题 ";
    }
}
开发者ID:xyzyx233,项目名称:QT_TcpServer,代码行数:43,代码来源:tcpclientsocket.cpp

示例7: path

/*!
  Constructs an assistant client with the specified \a parent. For
  systems other than Mac OS, \a path specifies the path to the Qt
  Assistant executable. For Mac OS, \a path specifies a directory
  containing a valid assistant.app bundle. If \a path is the empty
  string, the system path (\c{%PATH%} or \c $PATH) is used.
*/
QAssistantClient::QAssistantClient( const QString &path, QObject *parent )
    : QObject( parent ), host ( QLatin1String("localhost") )
{
#if defined(Q_OS_MAC)
    const QString assistant = QLatin1String("Assistant_adp");
#else
    const QString assistant = QLatin1String("assistant_adp");
#endif

    if ( path.isEmpty() )
        assistantCommand = assistant;
    else {
        QFileInfo fi( path );
        if ( fi.isDir() )
            assistantCommand = path + QLatin1String("/") + assistant;
        else
            assistantCommand = path;
    }

#if defined(Q_OS_MAC)
    assistantCommand += QLatin1String(".app/Contents/MacOS/Assistant_adp");
#endif

    socket = new QTcpSocket( this );
    connect( socket, SIGNAL(connected()),
            SLOT(socketConnected()) );
    connect( socket, SIGNAL(disconnected()),
            SLOT(socketConnectionClosed()) );
    connect( socket, SIGNAL(error(QAbstractSocket::SocketError)),
             SLOT(socketError()) );
    opened = false;
    proc = new QProcess( this );
    port = 0;
    pageBuffer = QLatin1String("");
    connect( proc, SIGNAL(readyReadStandardError()),
             this, SLOT(readStdError()) );
    connect( proc, SIGNAL(error(QProcess::ProcessError)),
        this, SLOT(procError(QProcess::ProcessError)) );
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:46,代码来源:qassistantclient.cpp

示例8: Q_D

bool QHttpSocketEngine::initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol)
{
    Q_D(QHttpSocketEngine);
    if (type != QAbstractSocket::TcpSocket)
        return false;

    setProtocol(protocol);
    setSocketType(type);
    d->socket = new QTcpSocket(this);
#ifndef QT_NO_BEARERMANAGEMENT
    d->socket->setProperty("_q_networkSession", property("_q_networkSession"));
#endif

    // Explicitly disable proxying on the proxy socket itself to avoid
    // unwanted recursion.
    d->socket->setProxy(QNetworkProxy::NoProxy);

    // Intercept all the signals.
    connect(d->socket, SIGNAL(connected()),
            this, SLOT(slotSocketConnected()),
            Qt::DirectConnection);
    connect(d->socket, SIGNAL(disconnected()),
            this, SLOT(slotSocketDisconnected()),
            Qt::DirectConnection);
    connect(d->socket, SIGNAL(readyRead()),
            this, SLOT(slotSocketReadNotification()),
            Qt::DirectConnection);
    connect(d->socket, SIGNAL(bytesWritten(qint64)),
            this, SLOT(slotSocketBytesWritten()),
            Qt::DirectConnection);
    connect(d->socket, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(slotSocketError(QAbstractSocket::SocketError)),
            Qt::DirectConnection);
    connect(d->socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
            this, SLOT(slotSocketStateChanged(QAbstractSocket::SocketState)),
            Qt::DirectConnection);

    return true;
}
开发者ID:phen89,项目名称:rtqt,代码行数:39,代码来源:qhttpsocketengine.cpp

示例9: QTcpSocket

bool NetworkConnection::openConnection(const QString & host, const unsigned short port, bool not_main_connection)
{	
	qsocket = new QTcpSocket();	//try with no parent passed for now
	if(!qsocket)
		return 0;
	//connect signals
	
	//connect(qsocket, SIGNAL(hostFound()), SLOT(OnHostFound()));
	connect(qsocket, SIGNAL(connected()), SLOT(OnConnected()));
	connect(qsocket, SIGNAL(readyRead()), SLOT(OnReadyRead()));
	connect(qsocket, SIGNAL(disconnected ()), SLOT(OnConnectionClosed()));
//	connect(qsocket, SIGNAL(delayedCloseFinished()), SLOT(OnDelayedCloseFinish()));
//	connect(qsocket, SIGNAL(bytesWritten(qint64)), SLOT(OnBytesWritten(qint64)));
    connect(qsocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(OnError(QAbstractSocket::SocketError)));

	if(qsocket->state() != QTcpSocket::UnconnectedState)
	{
		qDebug("Called openConnection while in state %d", qsocket->isValid());
		return 0;
	}
	//remove asserts later
	Q_ASSERT(host != 0);
	Q_ASSERT(port != 0);

	if(!not_main_connection)
		drawPleaseWait();

	qDebug("Connecting to %s %d...\n", host.toLatin1().constData(), port);
	// assume info.host is clean
	qsocket->connectToHost(host, (quint16) port);
	
	/* If dispatch does not have a UI, the thing that sets the UI
	 * will setupRoomAndConsole */
	/* Tricky now without dispatches... who sets up the UI?
	 * there's always a mainwindow... but maybe things aren't setup? */
	
	/* connectionInfo as a message with those pointers is probably a bad idea */
	return (qsocket->state() != QTcpSocket::UnconnectedState);
}
开发者ID:EPeillard,项目名称:qgo,代码行数:39,代码来源:networkconnection.cpp

示例10: QTcpSocket

void u3HClient::on_clientThread_Started()
{
	m_clientSocket = new QTcpSocket(this);
	if(m_clientSocket->setSocketDescriptor(m_socketDescriptor)) 
	{
		// when data ready to be read
		connect(m_clientSocket, SIGNAL(readyRead()), this, SLOT(on_clientSocket_DataReady()));
		connect(m_clientSocket, SIGNAL(disconnected()), this, SLOT(on_socketDisconnected()));

		packetBuilder *b = new packetBuilder(_hello, newclient);
		b->FinalizePacket();
		SendPacket(b);
	}
	else 
	{
		emit ClientFatalError(m_clientID, tr("Can't set descriptor on socket"));
		emit TerminateClient();
	}

	LogEvent("New client from : " + GetClientEndPointString());

}
开发者ID:und3ath,项目名称:u3h,代码行数:22,代码来源:u3HClient.cpp

示例11: locker

void TestLocalSocket_Peer::onNewConnection(quintptr socketDescriptor)
{
	LocalServer	*	src	=	qobject_cast<LocalServer*>(sender());
	
	if(src == 0)
		return;
	
	QWriteLocker	locker(&m_socketLock);
	
	QVERIFY(m_socket == 0);
	
	m_socket	=	new LocalSocket(this);
	
	connect(m_socket, SIGNAL(socketDescriptorWritten(quintptr)), SLOT(fileDescriptorWritten(quintptr)));
	connect(m_socket, SIGNAL(disconnected()), SLOT(onDisconnected()), Qt::DirectConnection);
	
	m_socket->setSocketDescriptor(socketDescriptor);
	
	QVERIFY(m_socket->open(QIODevice::ReadWrite));
	
	m_socketChanged.wakeAll();
}
开发者ID:HardcorEViruS,项目名称:MessageBus,代码行数:22,代码来源:testlocalsocket_peer.cpp

示例12: connect

void NfcPeerToPeer::handleNewConnection()
{
    if (!m_connectServerSocket)
        return;

    if (m_nfcServerSocket) {
        m_nfcServerSocket->deleteLater();
    }

    // The socket is a child of the server and will therefore be deleted automatically
    m_nfcServerSocket = m_nfcServer->nextPendingConnection();

    connect(m_nfcServerSocket, SIGNAL(readyRead()), this, SLOT(readTextServer()));
    connect(m_nfcServerSocket, SIGNAL(error(QLlcpSocket::SocketError)), this, SLOT(serverSocketError(QLlcpSocket::SocketError)));
    connect(m_nfcServerSocket, SIGNAL(stateChanged(QLlcpSocket::SocketState)), this, SLOT(serverSocketStateChanged(QLlcpSocket::SocketState)));
    connect(m_nfcServerSocket, SIGNAL(disconnected()), this, SLOT(serverSocketDisconnected()));

    if (m_reportingLevel != AppSettings::OnlyImportantReporting) {
        emit statusMessage("New server socket connection");
    }
    sendCachedText();
}
开发者ID:andijakl,项目名称:nfcinteractor,代码行数:22,代码来源:nfcpeertopeer.cpp

示例13: QObject

//----------------------------------------------------------------------------//
// QCanConfig()                                                                 //
// constructor                                                                //
//----------------------------------------------------------------------------//
QCanConfig::QCanConfig(QObject *parent) :
    QObject(parent)
{
   //----------------------------------------------------------------
   // get the instance of the main application
   //
   pclAppP = QCoreApplication::instance();

   
   //----------------------------------------------------------------
   // connect signals for socket operations
   //
   QObject::connect(&clCanSocketP, SIGNAL(connected()),
                    this, SLOT(socketConnected()));

   QObject::connect(&clCanSocketP, SIGNAL(disconnected()),
                    this, SLOT(socketDisconnected()));
   
   QObject::connect(&clCanSocketP, SIGNAL(error(QAbstractSocket::SocketError)),
                    this, SLOT(socketError(QAbstractSocket::SocketError)));
   
}
开发者ID:canpie,项目名称:CANpie,代码行数:26,代码来源:qcan_config.cpp

示例14: out

//! [4]
void Server::sendFortune()
{
//! [5]
    QByteArray block;
    QDataStream out(&block, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_4_0);
//! [4] //! [6]
    out << (quint16)0;
    out << fortunes.at(qrand() % fortunes.size());
    out.device()->seek(0);
    out << (quint16)(block.size() - sizeof(quint16));
//! [6] //! [7]

    QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
    connect(clientConnection, SIGNAL(disconnected()),
            clientConnection, SLOT(deleteLater()));
//! [7] //! [8]

    clientConnection->write(block);
    clientConnection->disconnectFromHost();
//! [5]
}
开发者ID:Kwangsub,项目名称:qt-openwebos,代码行数:23,代码来源:server.cpp

示例15: SkpTcpSocketTest

void SkpSocketTestWidget::skp_on_timer_socket()
{
    int threadIndex = m_connectNumber % THREAD_NUMBER;
    QThread *thread = m_threadList.at(threadIndex);
    m_connectNumber++;

    SkpTcpSocketTest *tcpSocketTest = new SkpTcpSocketTest();

    connect(tcpSocketTest, SIGNAL(connected()), tcpSocketTest, SLOT(skp_on_connect()));
    connect(tcpSocketTest, SIGNAL(readyRead()), tcpSocketTest, SLOT(skp_on_read()));
    connect(tcpSocketTest, SIGNAL(disconnected()), tcpSocketTest, SLOT(skp_on_disconnected()));
    connect(tcpSocketTest, SIGNAL(error(QAbstractSocket::SocketError)),
            tcpSocketTest, SLOT(skp_on_error(QAbstractSocket::SocketError)));

    connect(tcpSocketTest, SIGNAL(skp_sig_quit(qint64, qint64, qint64, qint64)), this, SLOT(skp_on_quit(qint64, qint64, qint64, qint64)));
    connect(tcpSocketTest, SIGNAL(skp_sig_socket_quit(qint64, qint64, qint64, qint64)), this, SLOT(skp_on_socket_quit(qint64, qint64, qint64, qint64)));

    tcpSocketTest->connectToHost(connectIP, connectPort);
    tcpSocketTest->waitForConnected();

    tcpSocketTest->moveToThread(thread);
}
开发者ID:yefy,项目名称:skp,代码行数:22,代码来源:skp_socket_test_widget.cpp


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