media @ VU
[] readme course(s) preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthought(s) appendix reference(s) example(s) resource(s) _

talk show tell print

simple-client.c

? / simple-client.c


  include <hush/source.h>
  include <socket/socket.h>
  
  include <iostream>
  
  using namespace std;
  
  int main() {
  
    try {
      SocketClient s("www.google.com", 80);
  
      s.SendLine("GET / HTTP/1.0");
      s.SendLine("Host: www.google.com");
      s.SendLine("");
  
      while (1) {
        string l = s.ReceiveLine();
        if (l.empty()) break;
        cout << l;
        cout.flush();
      }
  
    } 
    catch (const char* s) {
      cerr << s << endl;
    } 
    catch (std::string s) {
      cerr << s << endl;
    } 
    catch (...) {
      cerr << "unhandled exception\n";
    }
  
    return 0;
  }
  


(C) A. Eliëns 2/9/2007

You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.