本文整理汇总了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();
}
示例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!");
}
}
示例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;
}
示例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);
}
示例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();
}
示例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()<< "选题 ";
}
}
示例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)) );
}
示例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;
}
示例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);
}
示例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());
}
示例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();
}
示例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();
}
示例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)));
}
示例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]
}
示例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);
}