Ok, I'm trying this way:
int myPort = 80;
//this function establishes connection and returns immediately
m_pSocket->connectToHost(myHost, myPort);
connect(m_pSocket, SIGNAL(connected()), this, SLOT(connectedSlot()));
QString myHost("www.google.com");
int myPort = 80;
//this function establishes connection and returns immediately
m_pSocket->connectToHost(myHost, myPort);
connect(m_pSocket, SIGNAL(connected()), this, SLOT(connectedSlot()));
To copy to clipboard, switch view to plain text mode
void CMainWindow::connectedSlot() {
QString input
= "GET /index.php HTTP/1.1\n\n";
stream << input;
}
while(m_pSocket->canReadLine()) {
text += m_pSocket->readLine();
}
output >> text;
}
void CMainWindow::connectedSlot() {
QString input = "GET /index.php HTTP/1.1\n\n";
if(m_pSocket->state() == QAbstractSocket::ConnectedState) {
QTextStream stream(m_pSocket);
stream << input;
}
QString text;
while(m_pSocket->canReadLine()) {
text += m_pSocket->readLine();
}
QTextStream output(stdout);
QString enteredCommand = text;
output >> text;
}
To copy to clipboard, switch view to plain text mode
I'm calling this slot when the connecter() signal occurs, still does not work!
Bookmarks