std::cout << String(ip) << "\n";
- std::cout << "Finding www.noortict.nl\n";
- Host server(String("www.noortict.nl"));
- std::list<InternetAddress> iplist = server.FindAddress();
- std::list<InternetAddress>::iterator ipaddress;
- for (ipaddress = iplist.begin(); ipaddress != iplist.end(); ipaddress++)
- {
- std::cout << " IP address " << String(*ipaddress) << "\n";
- }
-
- Service srv("http");
- std::list<Port> portlist = srv.FindAddress();
- std::list<Port>::iterator port;
- for (port = portlist.begin(); port != portlist.end(); port++)
- {
- std::cout << " Port " << port->get_port() << ", socket type " << port->get_sockettype() << "\n";
- }
-
- IPSocketAddress serveraddress(iplist.front(), portlist.front());
- StreamSocket s;
-
- std::cout << "Connection result = " << s.Connect(serveraddress) << "\n";
- s.Write("GET / HTTP/1.1\n", 15);
- s.Write("Host: www.noortict.nl\n\n", 23);
-
- char buf[1000];
- int len;
- do
- {
- len = s.Read(buf, 1000);
- buf[len] = '\0';
- std::cout << "LEN = " << len << "\n" << buf << "\n";
- }
- while (len > 0);
}