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); // Explicitly disable proxying on the proxy socket itself to avoid // unwanted recursion. QNetworkProxy proxy; proxy.setType(QNetworkProxy::NoProxy); d->socket->setProxy(proxy); // Intercept all the signals. connect(d->socket, SIGNAL(connected()), this, SLOT(slotSocketConnected())); connect(d->socket, SIGNAL(disconnected()), this, SLOT(slotSocketDisconnected())); connect(d->socket, SIGNAL(readyRead()), this, SLOT(slotSocketReadNotification())); connect(d->socket, SIGNAL(readyRead()), this, SLOT(slotSocketReadNotification())); connect(d->socket, SIGNAL(bytesWritten(qint64)), this, SLOT(slotSocketBytesWritten())); connect(d->socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotSocketError(QAbstractSocket::SocketError))); connect(d->socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(slotSocketStateChanged(QAbstractSocket::SocketState))); return true; }
void Simulator::slotNewConnection(void) { logger->Simulator("Simulator::slotNewConnection(): new client connected."); socket = tcpServer->nextPendingConnection(); connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(slotSocketStateChanged(QAbstractSocket::SocketState))); connect(socket, SIGNAL(readyRead()), this, SLOT(slotDataReceived())); // close the server, one client is enough tcpServer->close(); }
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); d->reply = new QHttpNetworkReply(QUrl(), 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; }
Robot::Robot(void) { logger = Logger::instance(); logger->Robot("Robot::Robot()"); mutexThread = new QMutex(QMutex::NonRecursive); mutexRobot = new QMutex(QMutex::NonRecursive); config = Configuration::instance(); canSocket = new QTcpSocket(this); canSocket->connectToHost(QHostAddress::LocalHost, config->getCanServerPort()); connect(canSocket, SIGNAL(readyRead()), this, SLOT(slotIncomingCanPacket())); connect(canSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(slotSocketStateChanged(QAbstractSocket::SocketState))); qRegisterMetaType<RobotStatus>("RobotStatus"); brakesApplied = true; timeStamp = QTime::currentTime(); // Don't use slotSetStatus(idle), as that would fire an event. That's probably // not harmful, but still useless. currentRobotStatus = idle; }
MobileDClient::MobileDClient() : QMainWindow() { setupUi(this); setWindowTitle("MobileDClient"); logger = Logger::instance(); config = Configuration::instance(); socket = new QTcpSocket(this); socket->connectToHost(QHostAddress::LocalHost, 1234); connect(socket, SIGNAL(readyRead()), this, SLOT(slotIncomingPacket())); connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(slotSocketStateChanged(QAbstractSocket::SocketState))); connect(connectionConnect, SIGNAL(clicked()), this, SLOT(slotConnectToHost())); connect(connectionDisconnect, SIGNAL(clicked()), this, SLOT(slotDisconnectFromHost())); connect(poseGet, SIGNAL(clicked()), this, SLOT(slotPoseGet())); connect(poseSet, SIGNAL(clicked()), this, SLOT(slotPoseSet())); connect(caEnable, SIGNAL(clicked()), this, SLOT(slotCaEnable())); connect(caDisable, SIGNAL(clicked()), this, SLOT(slotCaDisable())); connect(moveSpline, SIGNAL(clicked()), this, SLOT(slotMoveSpline())); connect(moveRotate, SIGNAL(clicked()), this, SLOT(slotMoveRotate())); connect(moveTranslate, SIGNAL(clicked()), this, SLOT(slotMoveTranslate())); connect(moveStop, SIGNAL(clicked()), this, SLOT(slotMoveStop())); connect(robotStatusGet, SIGNAL(clicked()), this, SLOT(slotRobotStatusGet())); connect(scannerGet, SIGNAL(clicked()), this, SLOT(slotScannerGet())); connect(voltageGet, SIGNAL(clicked()), this, SLOT(slotVoltageGet())); connect(tempsGet, SIGNAL(clicked()), this, SLOT(slotTempsGet())); errDialog = new QErrorMessage(this); }