I'm curious, why doesn't this program work:

MAIN.CPP
Qt Code:
  1. #include <QApplication>
  2. #include "mainwindow.h"
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QApplication app(argc, argv);
  7. CMainWindow window;
  8. window.show();
  9.  
  10. //return app.exec();
  11. }
To copy to clipboard, switch view to plain text mode 



MAINWINDOW.H
Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. /**
  5. @author eleanor <eleanor@localhost>
  6. */
  7.  
  8. #include <QWidget>
  9. #include <QString>
  10. #include <QTextStream>
  11. #include <QTcpSocket>
  12. #include <QAbstractSocket>
  13. #include <QLabel>
  14.  
  15. class CMainWindow : public QWidget {
  16. public:
  17. CMainWindow(QWidget *parent=0);
  18.  
  19. ~CMainWindow();
  20.  
  21. private:
  22. QTcpSocket *m_pSocket;
  23. };
  24.  
  25. #endif
To copy to clipboard, switch view to plain text mode 



MAINWINDOW.CPP
Qt Code:
  1. #include "mainwindow.h"
  2.  
  3. CMainWindow::CMainWindow(QWidget *parent) : QWidget(parent) {
  4. //creating a socket
  5. m_pSocket = new QTcpSocket(this);
  6.  
  7.  
  8. QString myHost("www.google.com");
  9. int myPort = 80;
  10.  
  11. //this function establishes connection and returns immediately
  12. m_pSocket->connectToHost(myHost, myPort);
  13.  
  14. QString input = "GET /index.php HTTP/1.1\n\n";
  15. if(m_pSocket->state() == QAbstractSocket::ConnectedState) {
  16. QTextStream stream(m_pSocket);
  17. stream << input;
  18. }
  19.  
  20. QString text;
  21. while(m_pSocket->canReadLine()) {
  22. text += m_pSocket->readLine();
  23. }
  24.  
  25. QTextStream output(stdout);
  26. QString enteredCommand = text;
  27. output >> text;
  28. }
  29.  
  30.  
  31. CMainWindow::~CMainWindow() {
  32.  
  33. }
To copy to clipboard, switch view to plain text mode 

I would appreciate any tips. Thanks