ICQClientSocket::ICQClientSocket(QSocket *s) #endif { sock = s; if (sock == NULL) #ifdef HAVE_KEXTSOCK_H sock = new KExtendedSocket; sock->setSocketFlags(KExtendedSocket::outputBufferedSocket ); #else sock = new QSocket(this); bConnected = false; #endif #ifdef HAVE_KEXTSOCK_H QObject::connect(sock, SIGNAL(connectionSuccess()), this, SLOT(slotConnected())); QObject::connect(sock, SIGNAL(lookupFinished(int)), this, SLOT(slotLookupFinished(int))); QObject::connect(sock, SIGNAL(connectionFailed(int)), this, SLOT(slotError(int))); QObject::connect(sock, SIGNAL(closed(int)), this, SLOT(slotError(int))); #else QObject::connect(sock, SIGNAL(connected()), this, SLOT(slotConnected())); QObject::connect(sock, SIGNAL(connectionClosed()), this, SLOT(slotConnectionClosed())); QObject::connect(sock, SIGNAL(error(int)), this, SLOT(slotError(int))); #endif QObject::connect(sock, SIGNAL(readyRead()), this, SLOT(slotReadReady())); QObject::connect(sock, SIGNAL(bytesWritten(int)), this, SLOT(slotBytesWritten(int))); bInWrite = false; #ifdef HAVE_KEXTSOCK_H if (s) sock->enableRead(true); #endif }
void CClientComWorker::run() { MYLOG4CPP_DEBUG<<"CClientComWorker::run() begin"; { QMutexLocker lock(&m_mutex_SocketW); m_pSocketHandle = new QTcpSocket(); m_pSocketInfo = new CSocketInfo(); } // QObject::connect(m_pSocketHandle, SIGNAL(connected()), this, SLOT(slotConnected()), Qt::AutoConnection); QObject::connect(m_pSocketHandle, SIGNAL(disconnected()), this, SLOT(slotDisconnected()), Qt::AutoConnection); QObject::connect(m_pSocketHandle, SIGNAL(readyRead()), this, SLOT(slotReadyRead()), Qt::AutoConnection);//Qt::AutoConnection Qt::BlockingQueuedConnection QObject::connect(m_pSocketHandle, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError(QAbstractSocket::SocketError)), Qt::AutoConnection); m_WorkerState = WORK_STATE_BEGIN; m_WorkerState = WORK_STATE_WORKING; //slotConnectToServer(); MYLOG4CPP_DEBUG<<" "<<"m_strID="<<m_pSocketInfo->m_strID <<" "<<"class:"<<" "<<"CClientComWorker" <<" "<<"fun:"<<" "<<"run" <<" "<<"emit signalDisconnected()" <<" "<<"param:"<<" "<<"m_nHandle="<<m_nHandle; emit signalDisconnected(m_nHandle); MYLOG4CPP_DEBUG<<"CClientComWorker::run() exec() begin"; //QThread::exec() waits until QThread::exit() called exec(); MYLOG4CPP_DEBUG<<"CClientComWorker::run() exec() end"; // QObject::disconnect(m_pSocketHandle, SIGNAL(connected()), this, SLOT(slotConnected())); QObject::disconnect(m_pSocketHandle, SIGNAL(disconnected()), this, SLOT(slotDisconnected())); QObject::disconnect(m_pSocketHandle, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); QObject::disconnect(m_pSocketHandle, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError(QAbstractSocket::SocketError))); { QMutexLocker lock(&m_mutex_SocketW); if (NULL != m_pSocketHandle) { //m_pSocketHandle->waitForDisconnected(); m_pSocketHandle->close(); delete m_pSocketHandle; m_pSocketHandle = NULL; } if (NULL != m_pSocketInfo) { delete m_pSocketInfo; m_pSocketInfo = NULL; } } m_WorkerState = WORK_STATE_END; MYLOG4CPP_DEBUG<<"CClientComWorker::run() end"; }
MyClient::MyClient(const QString & hoststr, int port, QWidget * pwgt) : QWidget(pwgt), nextBlockSize(0) { tcpSocket = new QTcpSocket(this); // установить связь с сервером tcpSocket->connectToHost(hoststr, port); // сокет отправляет сигнал connected() как только будет создано соединение connect(tcpSocket, SIGNAL(connected()), SLOT(slotConnected())); // сокет отправляет сигнал readyRead() при готовности предоставить данные для чтения connect(tcpSocket, SIGNAL(readyRead()), SLOT(slotReadyRead())); // в случае возникновения ошибки сокет отправляет сигнал error connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError(QAbstractSocket::SocketError))); textInfo = new QTextEdit; textInput = new QLineEdit; textInfo->setReadOnly(true); QPushButton * cmd = new QPushButton("&Send"); connect(cmd, SIGNAL(clicked()), SLOT(slotSendToServer())); connect(textInput, SIGNAL(returnPressed()), this, SLOT(slotSendToServer())); QVBoxLayout * mainLayout = new QVBoxLayout; mainLayout->addWidget(new QLabel("<H1>Client</H1>")); mainLayout->addWidget(textInfo); mainLayout->addWidget(textInput); mainLayout->addWidget(cmd); setLayout(mainLayout); }
Client::Client(const QString &host, int port, QWidget *parent) : QWidget(parent), blockSize(0) { socket = new QTcpSocket(this); socket->connectToHost(host, port); connect(socket, SIGNAL(connected()), SLOT(slotConnected())); connect(socket, SIGNAL(readyRead()), SLOT(slotReadyRead())); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(slotError(QAbstractSocket::SocketError))); info = new QTextEdit; input = new QLineEdit; info->setReadOnly(true); QPushButton* button = new QPushButton("&Send"); connect(button, SIGNAL(clicked()), SLOT(slotSendToServer())); connect(input, SIGNAL(returnPressed()), SLOT(slotSendToServer())); QVBoxLayout* layout = new QVBoxLayout; layout->addWidget(new QLabel("<h1>Client</h1>")); layout->addWidget(info); layout->addWidget(input); layout->addWidget(button); setLayout(layout); }
xmppClient::xmppClient(QObject *parent) : QXmppClient(parent) , m_turnPort(0) , m_turnFinished(false) { bool check; Q_UNUSED(check); // add QXmppCallManager extension callManager = new QXmppCallManager; addExtension(callManager); check = connect(this, SIGNAL(connected()), this, SLOT(slotConnected())); Q_ASSERT(check); check = connect(this, SIGNAL(presenceReceived(QXmppPresence)), this, SLOT(slotPresenceReceived(QXmppPresence))); Q_ASSERT(check); check = connect(callManager, SIGNAL(callReceived(QXmppCall*)), this, SLOT(slotCallReceived(QXmppCall*))); Q_ASSERT(check); check = connect(&m_dns, SIGNAL(finished()), this, SLOT(slotDnsLookupFinished())); Q_ASSERT(check); }
MainWindow::MainWindow() { setUnifiedTitleAndToolBarOnMac( true ); r = new Comms(); createActions(); createToolBars(); createDocks(); contactsList = new QListWidget(); contactsList->setMinimumWidth( 150 ); contactsList->setMinimumHeight( 250 ); contactsList->setUniformItemSizes( true ); contactsList->setSpacing( 3 ); contactsList->setWordWrap( true ); connectBox = new ConnectBox(); setCentralWidget( connectBox ); QObject::connect( r, SIGNAL( sigConnected() ), this, SLOT( slotConnected() ) ); QObject::connect( r, SIGNAL( sigRoster( QStringList* ) ), this, SLOT( slotRoster( QStringList* ) ) ); QObject::connect( r, SIGNAL( sigRosterPresence(QString, QString) ), this, SLOT( slotRosterPresence(QString, QString) ) ); QObject::connect( r, SIGNAL( sigVCardReceived(QString,QString) ), this, SLOT( slotVCardReceived(QString,QString) ) ); QObject::connect( r, SIGNAL( sigMessage(QString,QString) ), this, SLOT( slotMessage(QString,QString) ) ); QObject::connect( connectBox, SIGNAL( tryConnection(QString,QString) ), this, SLOT( setIdents(QString,QString) ) ); timer = new QTimer( this ); QObject::connect( timer, SIGNAL( timeout() ), r, SLOT( slotReceive() ) ); QObject::connect( contactsList, SIGNAL( itemDoubleClicked(QListWidgetItem*) ), this, SLOT( slotLocalSession(QListWidgetItem*) ) ); }
Client::Client(const QString &strHost, int port, QWidget *parent) : QWidget(parent), nextBlockSize(0) { mySocket = new QTcpSocket(); mySocket->connectToHost(strHost, port); connect(mySocket, SIGNAL(connected()), this, SLOT(slotConnected())); connect(mySocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); connect(mySocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError(QAbstractSocket::SocketError))); txtInfo = new QTextEdit(); txtInput = new QLineEdit(); txtInfo->setReadOnly(true); QPushButton *send = new QPushButton("&Send"); connect(send, SIGNAL(clicked()), this, SLOT(slotSendToServer())); connect(txtInput, SIGNAL(returnPressed()), this, SLOT(slotSendToServer())); QVBoxLayout *form = new QVBoxLayout(this); form->addWidget(new QLabel("<H1>Client</H1>")); form->addWidget(txtInfo); form->addWidget(txtInput); form->addWidget(send); }
void SkServer::start() { if (m_server) { delete m_server; } m_server = new QTcpServer(this); qDebug() << "listen" << m_port; if (!m_server->listen(QHostAddress::Any, m_port)) { qDebug() << "error"; QMessageBox::critical(NULL, tr("SkytechX Server"), tr("Unable to start the server: %1.") .arg(m_server->errorString())); stateChange(); return; } else { m_server->setMaxPendingConnections(1); qDebug() << "listening" << m_server->isListening(); } stateChange(); connect(m_server, SIGNAL(newConnection()), this, SLOT(slotConnected())); }
Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); //setAttribute(Qt::WA_TranslucentBackground); setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); m_socket = 0; m_server = new QLocalServer(this); if ( !m_server->listen("TouchButtonServer") ) { QMessageBox::critical(this, tr("LocalServer"), tr("Unable to start the server: %1").arg(m_server->errorString())); delete m_server; m_server = 0; return; } connect(m_server, SIGNAL(newConnection()), this, SLOT(slotConnected())); qDebug("server created"); }
Server::Server(QObject *parent) : QObject(parent) { m_socket = 0; m_server = new QLocalServer(this); QFile::remove("/tmp/tbs.local"); if ( !m_server->listen("tbs.local") ) { qDebug("[Server::] Unable to start the server: %s", qPrintable(m_server->errorString())); delete m_server; m_server = 0; return; } connect(m_server, SIGNAL(newConnection()), this, SLOT(slotConnected())); m_button = new ButtonDialog[2]; m_button[0].setId(0); m_button[0].move(100, 0); m_button[1].setId(1); m_button[1].move(200, 0); connect(this, SIGNAL(signalCommandReceived(QString)), this, SLOT(slotCommandReceived(QString))); qDebug("[Server::] server created"); }
NetClient::NetClient() : blockSize(0) { tcpSocket = new QTcpSocket(this); connect(tcpSocket, SIGNAL(connected()), SLOT(slotConnected())); connect(tcpSocket, SIGNAL(readyRead()), SLOT(getResponse())); connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(netError(QAbstractSocket::SocketError))); }
/*! \~russian * \brief Метод предназначен для соединения внутренних сигналов и слотов класса. */ void TcpClient::connectSignalsAndSlots() { connect(&_socket, SIGNAL(connected()), SLOT(slotConnected())); connect(&_socket, SIGNAL(readyRead()), SLOT(slotReadyRead())); connect(&_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError(QAbstractSocket::SocketError)) ); }
Referee::Referee(int teamID, QObject *parent) : QObject(parent), messengerOfTheGods(new Hermes(this)), wLimit(1024), myTeamID(teamID), messageSize(0), connection( false), testMode(false), verbose(true), ready(false) { connect(messengerOfTheGods, SIGNAL(readyRead()), this, SLOT(slotRead())); connect(messengerOfTheGods, SIGNAL(connected()), this, SLOT(slotConnected())); connect(messengerOfTheGods, SIGNAL(disconnected()), this, SLOT(slotDisconnected())); }
void TcpClient::disconnectHost() { m_pTcpSocket->disconnectFromHost(); disconnect(m_pTcpSocket, SIGNAL(connected()), this, SLOT(slotConnected())); disconnect(m_pTcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); disconnect(m_pTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError(QAbstractSocket::SocketError))); emit connected(m_connectionState = -1); }
QXmppSocksClient::QXmppSocksClient(const QString &proxyHost, quint16 proxyPort, QObject *parent) : QTcpSocket(parent), m_proxyHost(proxyHost), m_proxyPort(proxyPort), m_step(ConnectState) { connect(this, SIGNAL(connected()), this, SLOT(slotConnected())); connect(this, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); }
checkguest::checkguest(bool s,QString n, QString p, QObject *parent) :QObject(parent) { signorlog=s; m_name=n; m_passwd=p; m_tcpSocket=new QTcpSocket(this); m_tcpSocket->connectToHost(QHostAddress("223.3.78.22"),31300); connect(this->m_tcpSocket,SIGNAL(connected()),this,SLOT(slotConnected())); }
OwnCloudClient::OwnCloudClient(QObject *parent) : QObject(parent) { connect(&m_networkManager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), this, SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*))); connect(&m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotReplyFinished(QNetworkReply*))); connect(&m_networkManager, SIGNAL(networkSessionConnected()), this, SLOT(slotConnected())); // connect(&m_networkManager, SIGNAL()) }
/// private function void CServerManager::connectToServer(const std::string& serverIP, const unsigned int m_serverPort) { m_tcpSocket = new QTcpSocket(this); m_tcpSocket->connectToHost(QString(serverIP.c_str()), m_serverPort); connect(m_tcpSocket, SIGNAL(connected()), this, SLOT(slotConnected())); connect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); connect(m_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this,SLOT(slotError(QAbstractSocket::SocketError))); }
client::client(QString host) { m_pTcpSocket = new QTcpSocket(this); m_pTcpSocket->connectToHost(host, nPort); connect(m_pTcpSocket, SIGNAL(connected()), SLOT(slotConnected())); connect(m_pTcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); connect(m_pTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError())); game = NULL; }
SIMClientSocket::SIMClientSocket(QSocket *s) { sock = s; if (sock == NULL) sock = new QSocket(this); QObject::connect(sock, SIGNAL(connected()), this, SLOT(slotConnected())); QObject::connect(sock, SIGNAL(connectionClosed()), this, SLOT(slotConnectionClosed())); QObject::connect(sock, SIGNAL(error(int)), this, SLOT(slotError(int))); QObject::connect(sock, SIGNAL(readyRead()), this, SLOT(slotReadReady())); QObject::connect(sock, SIGNAL(bytesWritten(int)), this, SLOT(slotBytesWritten(int))); bInWrite = false; }
void GameClient::connectToServer(const QString &server) { serverAddr = server; int socketNumber = 2327; tcpSocket = new QTcpSocket(this); tcpSocket->connectToHost(serverAddr, socketNumber); connect(tcpSocket, SIGNAL(connected()), SLOT(slotConnected())); connect(tcpSocket, SIGNAL(readyRead()), SLOT(slotReadyRead())); connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(slotError(QAbstractSocket::SocketError))); }
void MainWindow::connectToHost() { if (ui->le_connect->text() != "...") { m_pTcpSocket->connectToHost(ui->le_connect->text(), nPort); connect(m_pTcpSocket, SIGNAL(connected()), SLOT(slotConnected())); connect(m_pTcpSocket, SIGNAL(readyRead()), SLOT(slotReadyRead())); } else { ui->statusBar->showMessage("Enter Server IP Adress!"); } }
KNetworkConnector::KNetworkConnector( QObject *parent, const char */*name*/ ) : Connector( parent ) { kdDebug( 14151 ) << k_funcinfo << "New KNetwork connector." << endl; mErrorCode = KNetwork::KSocketBase::NoError; mByteStream = new KNetworkByteStream( this ); connect( mByteStream, SIGNAL ( connected () ), this, SLOT ( slotConnected () ) ); connect( mByteStream, SIGNAL ( error ( int ) ), this, SLOT ( slotError ( int ) ) ); mPort = 0; }
JabberConnector::JabberConnector ( QObject *parent ) : XMPP::Connector ( parent ) { kDebug() << "New Jabber connector."; mErrorCode = 0; mByteStream = new JabberByteStream ( this ); connect ( mByteStream, SIGNAL (connected()), this, SLOT (slotConnected()) ); connect ( mByteStream, SIGNAL (error(int)), this, SLOT (slotError(int)) ); }
void xmppClient::slotCallReceived(QXmppCall *call) { qDebug() << "Got call from:" << call->jid(); bool check = connect(call, SIGNAL(connected()), this, SLOT(slotConnected())); Q_ASSERT(check); check = connect(call, SIGNAL(finished()), this, SLOT(slotFinished())); Q_ASSERT(check); // accept call call->accept(); }
KNetworkConnector::KNetworkConnector( QObject *parent ) : Connector( parent ) { kdDebug( YAHOO_RAW_DEBUG ) << "New KNetwork connector." << endl; mErrorCode = KNetwork::KSocketBase::NoError; mByteStream = new KNetworkByteStream( this ); connect( mByteStream, SIGNAL ( connected () ), this, SLOT ( slotConnected () ) ); connect( mByteStream, SIGNAL ( error ( int ) ), this, SLOT ( slotError ( int ) ) ); mPort = 5510; }
Widget::Widget( QWidget * parent ) : QWidget( parent ) { createWidgets(); setWindowTitle( tr("Echo client %1").arg( PORT ) ); connect( &socket, SIGNAL( connected() ), SLOT( slotConnected() ) ); connect( &socket, SIGNAL( disconnected() ), SLOT( slotDisconnected() ) ); connect( &socket, SIGNAL( readyRead() ), SLOT( slotRead() ) ); tcpConnect(); }
KNetworkConnector::KNetworkConnector ( QObject *parent ) : Connector ( parent ) { kDebug () << "New KNetwork connector."; mErrorCode = 0; mByteStream = new KNetworkByteStream ( this ); connect ( mByteStream, SIGNAL (connected()), this, SLOT (slotConnected()) ); connect ( mByteStream, SIGNAL (error(int)), this, SLOT (slotError(int)) ); mPort = 0; }
/// \cond void QXmppBookmarkManager::setClient(QXmppClient *client) { bool check; Q_UNUSED(check); QXmppClientExtension::setClient(client); check = connect(client, SIGNAL(connected()), this, SLOT(slotConnected())); Q_ASSERT(check); check = connect(client, SIGNAL(disconnected()), this, SLOT(slotDisconnected())); Q_ASSERT(check); }
void CServerManager::disconnectFromServer() { m_connectToServer = false; m_tcpSocket->waitForDisconnected(0); m_tcpSocket->disconnectFromHost(); disconnect(m_tcpSocket, SIGNAL(connected()), this, SLOT(slotConnected())); disconnect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); disconnect(m_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this,SLOT(slotError(QAbstractSocket::SocketError))); delete m_tcpSocket; qDebug("Disconnect from server - end"); }