boost::asio

boost::asioすごいなー。

#include <iostream>
#include <string>

#define _WIN32_WINNT 0x0501
#include <boost/asio.hpp>

using namespace std;
using namespace boost::asio;

int main(int argc, char* argv[]) {
  ip::tcp::iostream s("www.boost.org", "http");

  s << "GET / HTTP/1.1\r\n";
  s << "Host: www.boost.org\r\n";
  s << "\r\n";
  s << flush;

  string l;

  while(getline(s, l)) {
    cout << l << endl;
  }

  return 0;
}