[asio] ip::tcp::iostream usage

The classic example: int main() { boost::asio::ip::tcp::iostream s("www.boost.org", "http"); s << "GET / HTTP/1.0\r\n"; s << "Host: www.boost.org\r\n"; s << "\r\n" << std::flush; std::cout << s.rdbuf(); return 0; } It works. But with a server on port 8080, it does not seem to work anymore. The host line was changed to s << "Host: www.boost.org:8080\r\n"; of course.

Dear Gregory, what changed is not the host but the port, i.e. the tcp port where the service is listening. So the host is still the same, as it's a hostname bound to the IP address to the boost site. While 8080 is no more "http" service. If you retry after changing "http" with 8080 (or the service name bound to 8080), it will work. Br, \Carlo Medas On Sun, Oct 5, 2008 at 6:54 AM, Gregory Dai <gregory.dai@gmail.com> wrote:
The classic example:
int main() { boost::asio::ip::tcp::iostream s("www.boost.org", "http");
s << "GET / HTTP/1.0\r\n"; s << "Host: www.boost.org\r\n"; s << "\r\n" << std::flush;
std::cout << s.rdbuf();
return 0; }
It works.
But with a server on port 8080, it does not seem to work anymore. The host line was changed to
s << "Host: www.boost.org:8080\r\n";
of course. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Thanks, Carlo. I googled an example that uses 9100 as port number and that did it. I was not patient enough waiting for a nice guy like you to give an answer. On Sun, Oct 5, 2008 at 1:07 AM, Carlo Medas <carlomedas@gmail.com> wrote:
Dear Gregory, what changed is not the host but the port, i.e. the tcp port where the service is listening.
So the host is still the same, as it's a hostname bound to the IP address to the boost site. While 8080 is no more "http" service. If you retry after changing "http" with 8080 (or the service name bound to 8080), it will work.
Br,
\Carlo Medas
On Sun, Oct 5, 2008 at 6:54 AM, Gregory Dai <gregory.dai@gmail.com> wrote:
The classic example:
int main() { boost::asio::ip::tcp::iostream s("www.boost.org", "http");
s << "GET / HTTP/1.0\r\n"; s << "Host: www.boost.org\r\n"; s << "\r\n" << std::flush;
std::cout << s.rdbuf();
return 0; }
It works.
But with a server on port 8080, it does not seem to work anymore. The host line was changed to
s << "Host: www.boost.org:8080\r\n";
of course. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Carlo Medas
-
Gregory Dai