void c_client::closeConnection() { socket->close(); if (socket->state() == QSocket::Closing) { connect(socket, SIGNAL(delayedCloseFinished()), SLOT(socketClosed())); } else { socketClosed(); } }
void TCPClient::closeConnection() { socket->close(); if ( socket->state() == QSocket::Closing ) { // We have a delayed close. connect( socket, SIGNAL(delayedCloseFinished()), SLOT(socketClosed()) ); } else { // The socket is closed. socketClosed(); } }
EventHandler::EventHandler(AbstractPluginSession *ps, MClientPlugin *mp) : MClientEventHandler(ps, mp) { _socketReader = new SocketReader(ps->session(), this); QString cfg = QString("config/"); // Host settings QString host = _config->value(cfg+"connection/host", "mume.org").toString(); int port = _config->value(cfg+"connection/port", "23").toInt(); _autoConnect = _config->value(cfg+"connection/autoconnect", true).toBool(); // Proxy settings QString proxy_host = _config->value(cfg+"proxy/host", "proxy.example.com").toString(); int proxy_port = _config->value(cfg+"proxy/port", "0").toInt(); QString proxy_user = _config->value(cfg+"proxy/proxy_user", "").toString(); QString proxy_pass = _config->value(cfg+"proxy/proxy_pass", "").toString(); if(proxy_port != 0 && !proxy_host.isEmpty()) { QNetworkProxy* proxy = new QNetworkProxy(); //proxy->setType(QNetworkProxy::Socks5Proxy); proxy->setHostName(proxy_host); proxy->setPort(proxy_port); proxy->setUser(proxy_user); proxy->setPassword(proxy_pass); _socketReader->proxy(proxy); qDebug() << "* added proxy" << proxy_host << proxy_port << "to SocketReader"; } _socketReader->host(host); _socketReader->port(port); // Signals and slots connect(this, SIGNAL(connectToHost()), _socketReader, SLOT(connectToHost())); connect(this, SIGNAL(closeSocket()), _socketReader, SLOT(closeSocket())); connect(this, SIGNAL(sendToSocket(const QByteArray &)), _socketReader, SLOT(sendToSocket(const QByteArray &))); connect(_socketReader, SIGNAL(socketReadData(const QByteArray &)), SLOT(socketReadData(const QByteArray &))); connect(_socketReader, SIGNAL(displayMessage(const QString &)), SLOT(displayMessage(const QString &))); connect(_socketReader, SIGNAL(socketOpened()), SLOT(socketOpened())); connect(_socketReader, SIGNAL(socketClosed()), SLOT(socketClosed())); }
void TQTcpServer::processIncoming() { while (server_->hasPendingConnections()) { // take ownership of the QTcpSocket; technically it could be deleted // when the QTcpServer is destroyed, but any real app should delete this // class before deleting the QTcpServer that we are using shared_ptr<QTcpSocket> connection(server_->nextPendingConnection()); shared_ptr<TTransport> transport; shared_ptr<TProtocol> iprot; shared_ptr<TProtocol> oprot; try { transport = shared_ptr<TTransport>(new TQIODeviceTransport(connection)); iprot = shared_ptr<TProtocol>(pfact_->getProtocol(transport)); oprot = shared_ptr<TProtocol>(pfact_->getProtocol(transport)); } catch(...) { qWarning("[TQTcpServer] Failed to initialize transports/protocols"); continue; } ctxMap_[connection.get()] = shared_ptr<ConnectionContext>( new ConnectionContext(connection, transport, iprot, oprot)); connect(connection.get(), SIGNAL(readyRead()), SLOT(beginDecode())); // need to use QueuedConnection since we will be deleting the socket in the slot connect(connection.get(), SIGNAL(disconnected()), SLOT(socketClosed()), Qt::QueuedConnection); } }
ProtoClientConnection::ProtoClientConnection(QTcpSocket *socket, Hyperion * hyperion) : QObject(), _socket(socket), _imageProcessor(ImageProcessorFactory::getInstance().newImageProcessor()), _hyperion(hyperion), _receiveBuffer() { // connect internal signals and slots connect(_socket, SIGNAL(disconnected()), this, SLOT(socketClosed())); connect(_socket, SIGNAL(readyRead()), this, SLOT(readData())); }
void TestabilityService::initializeConnections() { #if defined(TAS_NOLOCALSOCKET) mServerConnection = new QTcpSocket(this); #else mServerConnection = new QLocalSocket(this); #endif mSocket = new TasClientSocket(mServerConnection, this); connect(mSocket, SIGNAL(socketClosed()), this, SLOT(connectionClosed())); mSocket->setRequestHandler(mServiceManager); }
TCClientSocket::TCClientSocket( int port, QObject *parent ) : QTcpSocket( parent ) , miBlockSize(0) { line = 0; mConnectPort = port; connect( this, SIGNAL(connected()), this,SLOT(socketConnected()) ); connect( this, SIGNAL(disconnected()),this,SLOT(socketConnectionClosed()) ); connect( this, SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(socketError(QAbstractSocket::SocketError)) ); connect( this, SIGNAL(delayedCloseFinished()), SLOT(socketClosed()) ); connect( this, SIGNAL(readyRead()), this, SLOT(readyRead()) ); connect( this, SIGNAL(readyRead(TCClientSocket*)), parent, SLOT(readyRead(TCClientSocket*)) ); connect(this, SIGNAL(sendText(const QString&)),parent, SLOT(rcvSocketText(const QString&))); }
void TNotificationClient::run(){ if(serverHostname.isEmpty()){ return; } if(sock==0){ getSocket(); if(sock->isValid()){ connect(sock,SIGNAL(disconnected()),this,SLOT(socketClosed())); connect(sock,SIGNAL(readyRead()),this,SLOT(newDataAvailable())); } } exec(); }
void Connection::socketDisconnectedError( QAbstractSocket::SocketError e ) { tDebug() << "SOCKET ERROR CODE" << e << this->name() << "CALLING Connection::shutdown(false)"; if ( e == QAbstractSocket::RemoteHostClosedError ) return; d_func()->peer_disconnected = true; emit socketErrored(e); emit socketClosed(); shutdown( false ); }
void Connection::socketDisconnected() { tDebug() << "SOCKET DISCONNECTED" << this->name() << id() << "shutdown will happen after incoming queue empties." << "bytesavail:" << m_sock->bytesAvailable() << "bytesRecvd" << bytesReceived(); m_peer_disconnected = true; emit socketClosed(); if( m_msgprocessor_in.length() == 0 && m_sock->bytesAvailable() == 0 ) { handleIncomingQueueEmpty(); actualShutdown(); } }
/*! \brief Default constructor \param D Device to open the telnet connection to (it's passed to CLInterface) \note This function aborts if called with a device which doesn't support telnet access. This function opens the socket to the telnet interface and insert the password to access the CLI */ TelnetInterface::TelnetInterface(Device *D) : CLInterface(D) { if ( ! dev->hasTelnet() || ! dev->driver()->supportTelnet() ) throw ATMOS::EMissingSupport(ATMOS::EMissingSupport::msTelnet); s = new QSocket(this, "socket"); connect(s, SIGNAL(connected()), this, SLOT(socketConnected())); connect(s, SIGNAL(connectionClosed()), this, SLOT(socketClosed())); s->connectToHost( dev->IP(), dev->telnetPort() ); infoExp.push_back(QRegExp("logged on; type `@close' to close connection.\\r*\\n*")); infoExp.push_back(QRegExp("\\*\\*\\* telnet session will close in \\d+s\\r*\\n*")); termination = "\r\n"; }
void Connection::socketDisconnected() { Q_D( Connection ); qint64 bytesAvailable = 0; if ( !d->sock.isNull() ) { bytesAvailable = d->sock->bytesAvailable(); } tDebug( LOGVERBOSE ) << "SOCKET DISCONNECTED" << this->name() << id() << "shutdown will happen after incoming queue empties." << "bytesavail:" << bytesAvailable << "bytesRecvd" << bytesReceived(); d->peer_disconnected = true; emit socketClosed(); if ( d->msgprocessor_in.length() == 0 && bytesAvailable == 0 ) { handleIncomingQueueEmpty(); actualShutdown(); } }
/*! Destructor for TestabilityService */ TestabilityService::~TestabilityService() { mRegisterTime.stop(); mRegisterWatchDog.stop(); mPaintTracker.stop(); mEventService = 0; mFixtureService = 0; if(mSocket){ disconnect(mSocket, SIGNAL(socketClosed()), this, SLOT(connectionClosed())); mSocket->clearHandlers(); mSocket->closeConnection(); mSocket->deleteLater(); mSocket = 0; } if(mServerConnection){ mServerConnection->deleteLater(); mServerConnection = 0; } if(mServiceManager){ delete mServiceManager; mServiceManager = 0; } }
void SslTransport::disconnected(AsynchIO&) { close(); socketClosed(*aio, socket); }
void rice::pastry::socket::SocketPastryNodeFactory_getSocketCountListener_1::socketClosed(::java::lang::Object* i, ::java::util::Map* options) { socketClosed(dynamic_cast< ::java::net::InetSocketAddress* >(i), options); }